Building a Self-Hosted, Private AI Search Engine: Deploying Perplexica and SearXNG on a 4GB RAM VPS
The Paradigm Shift in Digital Search: The Rise of Private AI
In the contemporary digital landscape, knowledge acquisition is undergoing a massive transformation. Traditional search engines, which rely heavily on ad-tracking and data harvesting, are increasingly being challenged by AI-powered answer engines. Platforms like Perplexity AI have revolutionized how we find information by synthesizing web results into concise, direct answers. However, for enterprises, privacy-conscious professionals, and developers, relying on proprietary cloud solutions poses a significant risk: the commoditization of sensitive query data.
Fortunately, the open-source ecosystem offers a powerful antidote. By combining Perplexica (an open-source AI search engine wrapper) with SearXNG (a privacy-respecting metasearch engine), you can build a completely self-hosted, sovereign AI search infrastructure. In this technical guide, we will demonstrate how to architect and deploy this stack on a modest Virtual Private Server (VPS) with just 4GB of RAM, balancing cost-efficiency with uncompromising performance and privacy.
---Why Perplexica and SearXNG? Architectural Synergy
To understand why this specific stack is highly effective for business and enterprise use cases, we must examine the roles of both components:
- Perplexica: This acts as the intelligent orchestration layer. It takes user queries, utilizes advanced LLM agents to determine search intent, structures web-combing strategies, and refines the raw data into a coherent, cited response. It provides multiple modes such as Copilot, Academic, and Writing to tailor the AI's behavior.
- SearXNG: This serves as the privacy firewall and data aggregator. Instead of querying Google, Bing, or DuckDuckGo directly (which exposes your VPS's IP and search habits), SearXNG acts as a proxy metasearch engine. It aggregates results from dozens of search engines, strips out tracking cookies, anonymizes the requests, and returns clean results back to Perplexica.
By decoupling the search aggregation (SearXNG) from the LLM reasoning layer (Perplexica), you establish a local perimeter where your data remains strictly yours. No telemetry, no targeted advertising, and no data leaks.---
Prerequisites and Resource Optimization for a 4GB VPS
Running an AI-driven stack on a constrained resource footprint like a 4GB RAM VPS requires strategic planning. Local hosting of large language models (like Llama 3 or Mistral via Ollama) on 4GB of RAM is theoretically possible but practically sluggish due to heavy CPU/RAM utilization. Therefore, for an optimal enterprise workflow, we recommend a hybrid architecture:
- Local Execution: Host the web interfaces, agent logic, and SearXNG metasearch engines locally on your VPS using Docker.
- External Inference API: Connect Perplexica to high-performance, cost-effective API providers such as Groq, Together AI, or OpenAI. This keeps the VPS RAM consumption well under 2GB, leaving ample overhead for concurrent users and operating system stability.
System Requirements:
- A VPS running Ubuntu 22.04 LTS or 24.04 LTS.
- Minimum 2 vCPUs and 4GB of RAM.
- Docker and Docker Compose installed.
- An API key from a supported LLM provider (e.g., Groq for ultra-fast, sub-second inference).
Step-by-Step Deployment Guide
Step 1: System Preparation and Docker Installation
First, access your VPS via SSH and update the core repository packages. Ensure that Docker and its orchestration plugin are actively running on the host system.
sudo apt update && sudo apt upgrade -y
sudo apt install curl git software-properties-common -y
curl -fsSL [https://get.docker.com](https://get.docker.com) -o get-docker.sh
sudo sh get-docker.shStep 2: Configuring SearXNG as the Privacy Engine
We will pull the official SearXNG configuration and adapt it to communicate securely with Perplexica within the internal Docker bridge network. Clone your workspace directory and create the structure:
mkdir -p ~/private-search && cd ~/private-search
mkdir searxng && cd searxng
curl -o settings.yml [https://raw.githubusercontent.com/searxng/searxng/master/searxng/settings.yml](https://raw.githubusercontent.com/searxng/searxng/master/searxng/settings.yml)Edit the settings.yml file to ensure the output format includes JSON, which Perplexica requires to parse results:
search:
formats:
- html
- json
server:
secret_key: "generate_a_secure_random_string_here"
bind_address: "0.0.0.0"
port: 8080Step 3: Cloning and Initializing Perplexica
Navigate back to the root of your project directory and clone the Perplexica repository:
cd ~/private-search
git clone [https://github.com/ItzCrazyK0T/Perplexica.git](https://github.com/ItzCrazyK0T/Perplexica.git)
cd PerplexicaPerplexica provides an automated configuration script. Run it to set up your environment variables, specifying your LLM API provider and routing the search engine endpoint to your local SearXNG instance:
# Follow the interactive prompts to insert your API Keys and select your models
sh sample.config.shIn the generated configuration file, ensure the SEARXNG_URL is mapped correctly to your Docker service container name: http://searxng:8080.
Step 4: Orchestrating the Stack with Docker Compose
Create a unified docker-compose.yaml file within the main directory to seamlessly link both services, ensuring isolated networks and optimized resource limits.
version: '3.8'
services:
searxng:
image: searxng/searxng:latest
container_name: searxng
volumes:
- ./searxng/settings.yml:/etc/searxng/settings.yml:ro
ports:
- "8080:8080"
networks:
- search-network
restart: always
perplexica-backend:
image: itzcrazyk0t/perplexica-backend:latest
container_name: perplexica-backend
volumes:
- ./Perplexica/config.toml:/app/config.toml
networks:
- search-network
restart: always
perplexica-frontend:
image: itzcrazyk0t/perplexica-frontend:latest
container_name: perplexica-frontend
ports:
- "3000:3000"
networks:
- search-network
restart: always
networks:
search-network:
driver: bridgeLaunch the entire platform in detached mode:
docker compose up -d---Security Hardening and Production Considerations
Deploying tools directly to the internet via raw ports (e.g., port 3000) exposes your infrastructure to malicious scanning. To safeguard your proprietary search engine, implement the following enterprise security layers:
- Reverse Proxy with TLS Encryption: Utilize Nginx or Caddy to map your frontend port to a secure domain (e.g.,
search.yourcompany.com) equipped with Let's Encrypt SSL certificates. - HTTP Basic Authentication: Since Perplexica does not feature native multi-tenant user authentication out of the box, apply an authentication layer at the reverse proxy level to prevent unauthorized global access to your LLM API balances.
- UFW Firewall Rules: Close all external access to ports 8080 and 3000, forcing all inbound web traffic exclusively through the secure HTTPS port (443).
The Verdict: Corporate Autonomy Over Data
By executing this deployment, your enterprise gains a cutting-edge, conversational search tool identical in utility to commercial platforms, but with a foundational guarantee of total data privacy. Your corporate research trends, proprietary queries, and competitive intelligence gathering remain completely invisible to the outside world, secure on your sovereign VPS node. This hybrid stack exemplifies how modern open-source technology can democratize AI, putting computational sovereignty back into the hands of forward-thinking businesses.
