LiteLLM install with Nginx on Rocky Linux 10

Posted on Thu 22 January 2026 by Pavlo Khmel

Install packages:

dnf install -y postgresql-server postgresql nodejs tar git nginx
systemctl enable postgresql
postgresql-setup --initdb
systemctl restart postgresql

Create database with users with passwords:

sudo -i -u postgres psql
ALTER USER postgres WITH PASSWORD 'MyPostPassword';
CREATE USER litellm_admin WITH PASSWORD 'MyLitePassword';
\q
sudo -i -u postgres createdb litellmdb -O litellm_admin

Change connection access by modifying 2 lines in /var/lib/pgsql/data/pg_hba.conf:

# Before
# local   all             all                                     peer
# host    all             all             127.0.0.1/32            ident
# After
local   all             all                                     md5
host    all             all             127.0.0.1/32            md5

Increase number of connections:

# grep max_connections /var/lib/pgsql/data/postgresql.conf
#max_connections = 100      # (change requires restart)
max_connections = 500
systemctl restart postgresql

Test access

sudo -i -u postgres psql -U litellm_admin -d litellmdb
\q

LiteLLM installation:

useradd litellm
su - litellm
curl -LsSf https://astral.sh/uv/install.sh | sh
uv venv venv-litellm --python 3.12 --seed
source venv-litellm/bin/activate
uv pip install litellm[proxy]==1.80.11
uv pip install prisma
python -m prisma generate --schema venv-litellm/lib/python3.12/site-packages/litellm/proxy/schema.prisma

I was needed these commands for 1.80.12:

git clone https://github.com/BerriAI/litellm
DATABASE_URL="postgresql://litellm_admin:MyLitePassword@127.0.0.1:5432/litellmdb" python3 litellm/db_scripts/create_views.py

Example LiteLLM configuration file: /home/litellm/litellm_config.yaml

model_list:
  - model_name: "openai/gpt-oss-120b"
    litellm_params:
      model: "openai/openai/gpt-oss-120b"
      api_base: "http://10.1.1.6:8003/v1"
      api_key: "sk-MY-API-KEY"
    model_info:
      max_input_tokens: 65536
      max_output_tokens: 65536

  - model_name: "Qwen/Qwen3-Coder-30B-A3B-Instruct"
    litellm_params:
      model: "openai/Qwen/Qwen3-Coder-30B-A3B-Instruct"
      api_base: "http://10.1.1.6:8001/v1"
      api_key: "sk-MY-API-KEY"
    model_info:
      max_input_tokens: 131072
      max_output_tokens: 131072

router:
  num_retries: 3
  timeout: 60

logging:
  enabled: true
  log_level: "INFO"

general_settings: 
  master_key: "my-ADMIN-password!!!"
  database_url: "postgresql://litellm_admin:MyLitePassword@127.0.0.1:5432/litellmdb"

litellm_settings:
  request_timeout: 600
  set_verbose: False

Create LiteLLM service file /etc/systemd/system/litellm.service

[Unit]
Description=LiteLLM
After=network-online.target

[Service]
ExecStart=/bin/sh -c 'cd /home/litellm/ && source venv-litellm/bin/activate && litellm --num_workers 40 --port 4000 --config litellm_config.yaml --run_gunicorn --max_requests_before_restart 10000'
User=litellm
Group=litellm
Restart=always
RestartSec=3

[Install]
WantedBy=multi-user.target

Example Nginx proxy configuration /etc/nginx/conf.d/litellm.conf

upstream litellm {
    server 127.0.0.1:4000 max_fails=3 fail_timeout=10000s;
    keepalive 4096;
}

server {
    listen 443 ssl reuseport;
    server_name  litellm;
    ssl_certificate "/etc/pki/tls/certs/my.cert.pem";
    ssl_certificate_key "/etc/pki/tls/private/my.cert.key";
    ssl_protocols       TLSv1.2 TLSv1.3;
    ssl_ciphers         HIGH:!aNULL:!MD5;
    sendfile      on;
    client_max_body_size 100M;
    location / {
        proxy_pass http://litellm/;
        proxy_set_header Connection "";
        proxy_http_version 1.1;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_buffering off;
        proxy_set_header X-Accel-Buffering no;
        proxy_connect_timeout 3600s;
        proxy_read_timeout 3600s;
        proxy_send_timeout 3600s;
        send_timeout 3600s;
        proxy_buffers 16 64k;
        proxy_busy_buffers_size 128k;
    }
}

server {
    listen 80;
    listen [::]:80;
    server_name litellm;

    root /var/www/html/litellm;
    index index.html;

    location / {
        try_files $uri $uri/ =404;
    }
}

Increase number of worker_connections /etc/nginx/nginx.conf

events {
    worker_connections 65535;
    use epoll;
    multi_accept on;
}

Backup PostgreSQL

systemctl stop litellm
su - postgres

[postgres@llm ~]$ cat .pgpass
127.0.0.1:5432:*:postgres:MyPostPassword

chmod 600 .pgpass

pg_dumpall -U postgres -h 127.0.0.1 > full_backup_2026-01-24_0911.sql

systemctl start litellm

Restore PostgreSQL

Modify /var/lib/pgsql/data/pg_hba.conf

# Before
#local   all             all                                     md5
#host    all             all             127.0.0.1/32            md5
# After
local   all             all                                     peer
host    all             all             127.0.0.1/32            ident
systemctl restart postgresql
su - postgres

psql
drop litellmdb
\q
createdb litellmdb -O litellm_admin

In case of different PostgreSQL releases

sed -i '/^\\restrict/d;/^\\unrestrict/d' full_backup_2026-01-10_2252.sql

Restore

psql -f full_backup_2026-01-10_2252.sql

Modify /var/lib/pgsql/data/pg_hba.conf

# Before
# local   all             all                                     peer
# host    all             all             127.0.0.1/32            ident
# After
local   all             all                                     md5
host    all             all             127.0.0.1/32            md5

Restart

systemctl restart postgresql