> ## Content Index
> Fetch the complete content index at: https://blog.alphavps.com/llms.txt
> Use this file to discover other available public pages before exploring further.

# Install Grafana Loki on a Linux VPS for Log Management
- URL: https://blog.alphavps.com/install-grafana-loki-on-a-linux-vps-for-log-management/
- Published: 2026-02-02T08:15:05.000Z
- Updated: 2026-09-08T15:18:09.000Z
- Author: Karim Buzdar
- Tags: Tutorials, Monitoring & Logs, #series-log-management

Logs are essential in modern DevOps environments for debugging, monitoring, and maintaining the health of applications. Grafana Loki is a lightweight, cost-effective log management tool that can replace traditional log management software such as ELK. Loki is compatible with Grafana, Promtail, and other logging tools. This makes it the best log stack for Linux VPS environments.

This guide will show you how to install Grafana Loki, configure Grafana's visualization, and set up Promtail log collection.

## How to Install Grafana Loki on a Linux VPS for Log Management 

Grafana Loki, a log-aggregation tool inspired by Prometheus, is an aggregation software. It's optimized to store and query logs efficiently, without indexing all log content. Loki stores metadata in a separate location, which reduces storage and improves performance.

Grafana Loki is one of the easiest and most efficient ways to create a log management system that can scale. You get a powerful, lightweight logging stack that is suitable for both production servers and development environments.

Before installing Loki, ensure you have:

- A Linux VPS (Ubuntu/Debian/CentOS/AlmaLinux/RHEL)
- Root or sudo access
- Ports 3100 and 9080 (Loki) are allowed
- Grafana is optional but recommended

### Step 1: Create a Dedicated Loki Directory

Create directories for Loki files and config files.

```bash
sudo mkdir -p /etc/loki /var/lib/loki
```

![](https://blog.alphavps.com/content/images/2025/11/data-src-image-6b2ee85d-76f2-46cb-8984-7b751df66cc6.png)

Loki is able to store log files, config files, and chunks of data.

### Step 2: Download Loki Binary

Download the latest Loki Release:

```bash
cd /usr/local/bin
sudo wget https://github.com/grafana/loki/releases/latest/download/loki-linux-amd64.zip
```

![](https://blog.alphavps.com/content/images/2025/11/data-src-image-2cac1700-2983-4a5c-991a-ec393ba6d0db.png)

Let’s get the executable permissions:

```bash
sudo unzip loki-linux-amd64.zip
sudo chmod +x loki-linux-amd64
sudo mv loki-linux-amd64 loki
```

![](https://blog.alphavps.com/content/images/2025/11/data-src-image-f796f6ab-db2f-42f0-912d-8346980a40d9.png)

Loki is ready to go.

### Step 3: Create Loki Configuration File

Create the main configuration file:

```bash
sudo nano /etc/loki/loki-config.yml
```

Copy the minimal Loki configuration:

```bash
auth_enabled: false
server:
  http_listen_port: 3100
ingester:
  lifecycler:
    address: 127.0.0.1
    ring:
      kvstore:
        store: inmemory
      replication_factor: 1
  chunk_idle_period: 3m
  chunk_retain_period: 1m
schema_config:
  configs:
  - from: 2020-10-24
    store: boltdb
    object_store: filesystem
    schema: v11
    index:
      prefix: index_
      period: 24h
storage_config:
  boltdb:
    directory: /var/lib/loki/index
  filesystem:
    directory: /var/lib/loki/chunks
limits_config:
  ingestion_rate_mb: 4
  max_cache_freshness_per_query: 10m
```

![](https://blog.alphavps.com/content/images/2025/11/data-src-image-b1a4a7fa-70c2-47d9-8879-cf9d16e271e5.png)

Save and exit.

### Step 4: Create Loki systemd Service

Allow Loki to be run in the background:

```bash
sudo nano /etc/systemd/system/loki.service
```

Add:

```ini
[Unit]
Description=Loki Log Aggregation System
After=network.target
[Service]
ExecStart=/usr/local/bin/loki -config.file=/etc/loki/loki-config.yml
Restart=always
User=root
[Install]
WantedBy=multi-user.target
```

![](https://blog.alphavps.com/content/images/2025/11/data-src-image-c2b4a992-6647-434f-869f-67a72e5b3288.png)

Reload the system:

```bash
sudo systemctl daemon-reload
sudo systemctl start loki
sudo systemctl enable loki
```

![](https://blog.alphavps.com/content/images/2025/11/data-src-image-6770b786-acf7-4660-803b-37e01716f451.png)

### Step 5: Install Promtail (Log Collector)

Promtail sends Loki logs collected from your VPS. Let’s download Promtail:

```bash
cd /usr/local/bin
sudo wget https://github.com/grafana/loki/releases/latest/download/promtail-linux-amd64.zip
```

![](https://blog.alphavps.com/content/images/2025/11/data-src-image-ab98d1fa-18a0-4671-b6cc-18d0c857ac05.png)

Let’s get the executable permission:

```bash
sudo unzip promtail-linux-amd64.zip
sudo chmod +x promtail-linux-amd64
sudo mv promtail-linux-amd64 promtail
```

![](https://blog.alphavps.com/content/images/2025/11/data-src-image-31fcb8da-04d1-460f-809d-d230c92a3774.png)

### Step 6: Create Promtail Configuration File

Now, create the configuration file:

```bash
sudo nano /etc/loki/promtail-config.yml
```

Paste:

```bash
server:
  http_listen_port: 9080
positions:
  filename: /var/lib/promtail/positions.yaml
clients:
  - url: http://localhost:3100/loki/api/v1/push
scrape_configs:
  - job_name: system
    static_configs:
      - targets:
          - localhost
        labels:
          job: syslog
          __path__: /var/log/*.log
```

![](https://blog.alphavps.com/content/images/2025/11/data-src-image-05256f7a-ebfd-4531-b42f-c9e4f41ef537.png)

Create the directory: 

```bash
sudo mkdir -p /var/lib/promtail
```

![](https://blog.alphavps.com/content/images/2025/11/data-src-image-5e5c527d-7c62-4b41-ad03-f332d8807c95.png)

### Step 7: Create Promtail systemd Service

Now, create the services:

```bash
sudo nano /etc/systemd/system/promtail.service
```

Add:

```ini
[Unit]
Description=Promtail Log Collector
After=network.target
[Service]
ExecStart=/usr/local/bin/promtail -config.file=/etc/loki/promtail-config.yml
Restart=always
User=root
[Install]
WantedBy=multi-user.target
```

![](https://blog.alphavps.com/content/images/2025/11/data-src-image-bd9dd769-6d18-47d9-a329-e8b368633fe2.png)

Enable and start:

```bash
sudo systemctl daemon-reload
sudo systemctl start promtail
sudo systemctl enable promtail
```

![](https://blog.alphavps.com/content/images/2025/11/data-src-image-0f425324-94f5-44d2-9fac-bc08d030a13f.png)

Check status:

```bash
sudo systemctl status promtail
```

![](https://blog.alphavps.com/content/images/2025/11/data-src-image-e8a60e90-ae2b-43f5-bc7c-92581b94b81b.png)

### Step 8: Install Grafana (Optional but Recommended)

Grafana enables powerful log visualization. Let’s install:

```bash
sudo apt install grafana -y
```

![](https://blog.alphavps.com/content/images/2025/11/data-src-image-8836006e-7008-410b-9479-476488cf4d85.png)

Let’s enable the services of Grafana:

```bash
sudo systemctl enable --now grafana-server
```

![](https://blog.alphavps.com/content/images/2025/11/data-src-image-6ef1f958-b92f-4a17-8c28-07d7a80f4560.png)

Access Grafana:

```text
http://<your-ip>:3000
```

![](https://blog.alphavps.com/content/images/2025/11/data-src-image-84163eba-0644-49e3-83f3-945f830bf15e.png)

### Step 9: Test Your Logging Setup

Run a test log:

```bash
logger "Hello from Loki!"
```

![](https://blog.alphavps.com/content/images/2025/11/data-src-image-e840d6e9-2ddd-4ad6-b116-276d605c91ac.png)

You should now see live logs streaming from your VPS!

![](https://blog.alphavps.com/content/images/2025/11/data-src-image-35f21483-8b8b-4f25-a555-bb653728e645.png)

That is all from the guide.

## Conclusion

To install Grafana Loki on a Linux VPS for log management, create directories for Loki, download the Loki binary, and place a minimal configuration file in /etc/loki/loki-config.yml, then set up a systemd service to run Loki on port 3100\. Install Promtail next by downloading the binary, creating a file that directs logs like /var/log/\*.log to Loki, and enabling it as a systemd service. Finally, install Grafana, add Loki as a data source using http://localhost:3100, and start querying logs through Grafana's Explore tab for complete centralized log management on your server.

Do you want to install Grafana Loki on a Linux VPS and manage logs? Consider our [**Storage VPS**](https://alphavps.com/storage-vps.html?ref=blog.alphavps.com) solution for your project.