Installing AnythingLLM on Ubuntu: Build Your Own Ultra-Secure Local AI Knowledge Base

Artificial Intelligence tutorial - IT technology blog
Artificial Intelligence tutorial - IT technology blog

Data Leakage Concerns and “Instant” RAG Solutions

When working on enterprise projects or handling client data, the biggest fear is leaking business secrets by “exposing” documents to OpenAI or Claude. Previously, I guided you on building RAG using LangChain and Python. However, that approach is quite labor-intensive as you have to manually code everything from the vector database and embedding processing to the user interface.

If you need a practical, “plug-and-play” solution with a professional interface like ChatGPT, AnythingLLM is the top choice. This tool bundles the entire RAG (Retrieval-Augmented Generation) system into a single package. From the Vector Database (LanceDB) and Embedding engine to Workspace management, everything is included. I deployed this system for a technical team to look up internal API documentation, and the response performance was impressive, taking only about 1-2 seconds per query.

Hardware and Environment Preparation

Don’t underestimate the hardware requirements if you want the system to run smoothly, especially when combining it with Ollama to process models locally. Here are my recommended specs for an Ubuntu server:

  • Operating System: Ubuntu 22.04 LTS or 24.04 LTS (most stable).
  • RAM: Minimum 8GB. If running Llama 3 or Mistral locally, 16GB or more is preferred.
  • Storage: 20GB free SSD. LanceDB is very storage-efficient; 1GB can hold tens of thousands of text document pages.
  • Tools: Docker and Docker Compose pre-installed.

Deploying AnythingLLM with Docker

DevOps engineers and System Admins often prefer Docker for easy management and backups. This method completely isolates the application from the main system, avoiding library conflicts.

First, create a directory for persistent data. This ensures you don’t lose your documents when updating the container:

export STORAGE_LOCATION=$HOME/anythingllm
mkdir -p $STORAGE_LOCATION
touch "$STORAGE_LOCATION/.env"

Next, start the container using the docker run command. This will automatically pull the latest image to your machine:

docker run -d -p 3001:3001 \
--cap-add SYS_ADMIN \
-v "$STORAGE_LOCATION:/app/storage" \
-v "$STORAGE_LOCATION/.env:/app/server/.env" \
--name anythingllm \
--restart always \
mintplexlabs/anythingllm

Note: The --cap-add SYS_ADMIN flag is extremely important. It allows AnythingLLM to run sandbox processes to safely handle complex file formats. If you prefer using Docker Compose for centralized management, use the following configuration file:

version: '3.8'
services:
  anythingllm:
    image: mintplexlabs/anythingllm
    container_name: anythingllm
    ports:
      - "3001:3001"
    cap_add:
      - SYS_ADMIN
    volumes:
      - ./storage:/app/storage
      - ./.env:/app/server/.env
    restart: always

Detailed RAG System Configuration

Once the container is “up,” access http://your-server-ip:3001 to start the setup wizard.

1. Setting Up the LLM Engine

This is the brain that processes queries. You have two main options:

  • Local LLM (Ollama): The optimal choice for security. If your server has a GPU, install Ollama and connect via URL http://172.17.0.1:11434. All data remains 100% within your infrastructure.
  • Cloud LLM (OpenAI/Claude): Suitable if your server is underpowered but you need high intelligence. Only your queries are sent out, while the original documents stay local.

2. Embedding and Vector Database

Embedding is the step that transforms documents into numerical vectors. AnythingLLM has a lightweight built-in engine; I recommend keeping the default. For the Vector Database, the system uses LanceDB. This is a high-performance serverless database. In practice, with a library of fewer than 10,000 files, LanceDB responds almost instantly, far outperforming complex solutions like Pinecone or ChromaDB in the same category.

3. Workspace and Data Management

AnythingLLM’s structure is based on Workspaces. You can partition access: one for “Engineering,” one for “Legal.”

  • Access the Workspace and select Upload documents.
  • The system supports drag-and-drop for PDF, Docx, TXT, or fetching data directly from URLs.
  • After uploading, don’t forget to click Move to Workspace and Save and Embed for the system to start chunking and saving to the database.

Operation and Optimization

Try asking a question about the content you just uploaded. Unlike standard chat, AnythingLLM will clearly list citations (showing which file and which segment). This completely eliminates AI “hallucinations.”

Resource Monitoring

During the Embedding process, CPU usage usually spikes. This is normal. However, if RAM frequently exceeds 90%, you should limit the number of parallel files processed or upgrade your resources:

docker stats anythingllm

Nginx Reverse Proxy Configuration

To allow your team to access via a professional domain like ai.yourcompany.com, use Nginx as a frontend reverse proxy:

server {
    listen 80;
    server_name ai.yourcompany.com;

    location / {
        proxy_pass http://localhost:3001;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
    }
}

Using AnythingLLM saves you weeks of building a RAG system from scratch. It is the perfect intersection of user simplicity and technical control. If you encounter any issues during installation, leave a comment below, and I’ll help you troubleshoot.

Share: