This guide deploys AnythingLLM with native installation (Node.js, Python) on Debian 10 to latest stable, Ubuntu LTS (20.04+), and RHEL 9+ compatible hosts.
Note: For Docker-based deployment, see AnythingLLM Docker Ansible Setup.
- name: Deploy AnythingLLM (Native)
hosts: anythingllm
become: true
vars:
app_root: /opt/anythingllm
app_user: anythingllm
app_group: anythingllm
app_port: 3001
nodejs_version: "20"
# Generate secure secrets
jwt_secret: "{{ lookup('password', '/dev/null length=64 chars=hexdigits') }}"
gateway_token: "{{ lookup('password', '/dev/null length=32 chars=hexdigits') }}"
tasks:
# ====================
# System Dependencies
# ====================
- name: Install system dependencies (Debian/Ubuntu)
apt:
name:
- git
- curl
- wget
- build-essential
- libssl-dev
- python3
- python3-pip
- nginx
state: present
update_cache: true
when: ansible_os_family == "Debian"
- name: Install system dependencies (RHEL family)
dnf:
name:
- git
- curl
- wget
- "@Development Tools"
- openssl-devel
- python3
- python3-pip
- nginx
state: present
when: ansible_os_family == "RedHat"
# ====================
# Create Application User
# ====================
- name: Create AnythingLLM group
group:
name: "{{ app_group }}"
state: present
- name: Create AnythingLLM user
user:
name: "{{ app_user }}"
group: "{{ app_group }}"
shell: /bin/false
system: true
create_home: false
# ====================
# Node.js Setup
# ====================
- name: Install Node.js (Debian/Ubuntu)
block:
- name: Add NodeSource repository
apt_repository:
repo: "deb https://deb.nodesource.com/node_{{ nodejs_version }}.x {{ ansible_distribution_release }} main"
state: present
filename: nodesource
- name: Install Node.js
apt:
name: nodejs
state: present
update_cache: true
when: ansible_os_family == "Debian"
- name: Install Node.js (RHEL)
block:
- name: Install Node.js
dnf:
name: nodejs
state: present
when: ansible_os_family == "RedHat"
# ====================
# Clone Repository
# ====================
- name: Create application directory
file:
path: "{{ app_root }}"
state: directory
owner: "{{ app_user }}"
group: "{{ app_group }}"
mode: "0755"
- name: Clone AnythingLLM repository
git:
repo: https://github.com/Mintplex-Labs/anything-llm.git
dest: "{{ app_root }}"
depth: 1
version: master
become_user: "{{ app_user }}"
# ====================
# Backend Setup
# ====================
- name: Create storage directory
file:
path: "{{ app_root }}/server/storage"
state: directory
owner: "{{ app_user }}"
group: "{{ app_group }}"
mode: "0755"
- name: Install backend dependencies
command: npm ci
args:
chdir: "{{ app_root }}/server"
become_user: "{{ app_user }}"
- name: Build backend
command: npm run build
args:
chdir: "{{ app_root }}/server"
become_user: "{{ app_user }}"
- name: Create backend .env file
copy:
dest: "{{ app_root }}/server/.env"
owner: "{{ app_user }}"
group: "{{ app_group }}"
mode: "0600"
content: |
# Storage configuration
STORAGE_DIR={{ app_root }}/server/storage
WORKSPACES_DIR={{ app_root }}/server/storage/workspaces
# Security settings
JWT_SECRET={{ jwt_secret }}
MULTI_USER_MODE=false
# Network settings
PORT={{ app_port }}
HOST=0.0.0.0
# Gateway token for API access
GATEWAY_TOKEN={{ gateway_token }}
# ====================
# Frontend Setup
# ====================
- name: Install frontend dependencies
command: npm ci
args:
chdir: "{{ app_root }}/frontend"
become_user: "{{ app_user }}"
- name: Build frontend
command: npm run build
args:
chdir: "{{ app_root }}/frontend"
become_user: "{{ app_user }}"
# ====================
# Systemd Services
# ====================
- name: Create AnythingLLM systemd service
copy:
dest: /etc/systemd/system/anythingllm.service
mode: "0644"
content: |
[Unit]
Description=AnythingLLM Server
After=network.target
[Service]
Type=simple
User={{ app_user }}
Group={{ app_group }}
WorkingDirectory={{ app_root }}/server
Environment="NODE_ENV=production"
Environment="STORAGE_DIR={{ app_root }}/server/storage"
Environment="JWT_SECRET={{ jwt_secret }}"
Environment="PORT={{ app_port }}"
ExecStart=/usr/bin/npm run start
Restart=always
RestartSec=10
LimitNOFILE=65535
[Install]
WantedBy=multi-user.target
- name: Reload systemd
systemd:
daemon_reload: true
- name: Enable and start AnythingLLM
systemd:
name: anythingllm
enabled: true
state: started
# ====================
# Nginx Reverse Proxy
# ====================
- name: Create Nginx configuration
copy:
dest: /etc/nginx/sites-available/anythingllm
mode: "0644"
content: |
server {
listen 80;
server_name _;
location / {
proxy_pass http://localhost:{{ app_port }};
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
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_set_header X-Forwarded-Proto $scheme;
}
}
- name: Enable Nginx site
file:
src: /etc/nginx/sites-available/anythingllm
dest: /etc/nginx/sites-enabled/anythingllm
state: link
when: ansible_os_family == "Debian"
- name: Enable and start Nginx
service:
name: nginx
state: started
enabled: true
# ====================
# Final Status
# ====================
- name: Wait for AnythingLLM to be ready
uri:
url: "http://localhost:{{ app_port }}/api/health"
method: GET
status_code: 200
register: health_check
retries: 30
delay: 10
until: health_check.status == 200
ignore_errors: true
- name: Display deployment information
debug:
msg: |
AnythingLLM has been deployed successfully!
ACCESS:
- URL: http://{{ ansible_host | default(inventory_hostname) }}:{{ app_port }}
STORAGE:
- Location: {{ app_root }}/server/storage
IMPORTANT:
- Complete the setup wizard in the Web UI
- Configure your LLM provider (OpenAI, Anthropic, Ollama, etc.)
- Store API keys securely in the Web UI
- Do not expose port {{ app_port }} directly to the internet
- Configure TLS/HTTPS before exposing to production
ansible-playbook -i inventory.ini deploy-anythingllm-native.yml
ansible-vault create group_vars/all/vault.yml
Add your secrets:
jwt_secret: "your-64-character-jwt-secret"
gateway_token: "your-32-character-token"
Run with vault:
ansible-playbook -i inventory.ini deploy-anythingllm-native.yml --ask-vault-pass
Open your browser and navigate to http://your-server-ip:3001
systemctl status anythingllm
journalctl -u anythingllm -f
cd /opt/anythingllm
sudo -u anythingllm git pull
sudo -u anythingllm npm ci --prefix server
sudo -u anythingllm npm run build --prefix server
sudo systemctl restart anythingllm
# Backup storage directory
tar -czf anythingllm-backup-$(date +%Y%m%d).tar.gz /opt/anythingllm/server/storage
We develop tailored automation solutions for:
Let’s discuss your requirements: office@linux-server-admin.com | Contact