Building a Personal AI Search Engine: Deploying Perplexica and SearXNG on a Cost-Effective 2GB RAM VPS
Introduction: The Shift Toward Privacy-Centric AI Search
In the rapidly evolving landscape of artificial intelligence, search engines are undergoing a massive paradigm shift. Traditional search engines index the web but require manual filtering through pages of links. Modern AI-powered search engines, like Perplexity AI, solve this by synthesizing web data directly into coherent, cited answers. However, relying on commercial proprietary platforms introduces critical concerns regarding data privacy, subscription costs, and vendor lock-in.
For enterprise users, professionals, and developers, the ideal solution is a self-hosted alternative. This technical guide provides a step-by-step blueprint to deploy Perplexica (an open-source AI search engine) integrated with SearXNG (a privacy-respecting metasearch engine) on a resource-constrained VPS with only 2GB of RAM. By the end of this article, you will possess a private, secure, and highly cost-effective AI search infrastructure tailored to your professional needs.
---Understanding the Architecture: Perplexica and SearXNG
Before diving into the implementation, it is crucial to understand how these two components interact to deliver accurate, real-time results while maintaining a low memory footprint.
- Perplexica: Acting as the frontend brain, Perplexica utilizes Large Language Models (LLMs) to understand user intent, structure search queries, and synthesize the fetched data into a final response. It supports various local models via Ollama or cloud-based APIs like Groq, OpenAI, and Anthropic.
- SearXNG: This serves as the data retrieval engine. It is a internet metasearch engine that aggregates results from dozens of search engines (Google, Bing, DuckDuckGo) without tracking user behavior or sharing data with third parties. Perplexica queries SearXNG to pull fresh web results, which it then processes using the LLM.
By decoupling the search aggregation (SearXNG) from the cognitive synthesis (Perplexica), you establish a modular architecture that ensures both data sovereignty and high flexibility in model selection.---
Prerequisites and Environment Optimization
Deploying an AI stack on a 2GB RAM VPS requires aggressive resource management. Attempting to run heavy local LLMs directly on this server will instantly trigger Out-Of-Memory (OOM) errors. Therefore, our optimization strategy relies on utilizing lightweight containerized services and offloading the heavy computational workload to external, high-speed API providers.
1. Hardware Requirements
- VPS Specifications: 1 or 2 vCPUs, 2GB RAM, 20GB SSD/NVMe Storage.
- OS: Ubuntu 22.04 LTS or Ubuntu 24.04 LTS.
- Network: Static Public IP address with ports 80, 443, and necessary service ports open.
2. Preparing the Server with Swap Memory
To prevent the Linux kernel from killing our Docker containers during peak operations, we must configure a swap file to act as a memory buffer. Run the following commands sequentially via SSH:
sudo fallocate -l 2G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstabVerify the setup by executing free -m. You should now see 2GB of physical RAM supplemented by 2GB of swap space, offering a crucial safety net for our services.
Step-by-Step Deployment Guide
We will leverage Docker Compose to orchestrate our infrastructure. This ensures isolation, easy updates, and minimal manual configuration.
Step 1: Installing Docker and Git
Ensure your system package lists are updated and install the essential dependencies:
sudo apt update && sudo apt upgrade -y
sudo apt install git docker.io docker-compose -y
sudo systemctl enable --now dockerStep 2: Configuring SearXNG
First, create a dedicated directory for your search stack and set up the SearXNG configuration files:
mkdir -p ~/ai-search/searxng && cd ~/ai-search/searxngCreate a settings.yml file to configure SearXNG to output results in JSON format, which allows Perplexica to parse the data correctly:
# settings.yml
search:
formats:
- html
- json
server:
port: 8080
bind_address: "0.0.0.0"
secret_key: "super_secret_unique_key_here"
ui:
theme: simpleNote: Ensure you change the secret_key to a unique, randomly generated string to secure your metasearch backend.Step 3: Setting Up Perplexica
Navigate back to your root directory and clone the official Perplexica repository:
cd ~/ai-search
git clone [https://github.com/ItzCrazyK0/Perplexica.git](https://github.com/ItzCrazyK0/Perplexica.git)
cd PerplexicaInside the Perplexica directory, rename the template environment file to activate configuration:
cp sample.config.toml config.tomlEdit the config.toml file to point its search provider to your local SearXNG instance. Modify the following parameters:
[GENERAL]
PORT = 3000
[SEARCH_PROVIDER]
PROVIDER = "searxng"
SEARXNG_URL = "http://searxng:8080"Step 4: Unified Docker Compose Orchestration
To tie both applications together seamlessly under a single network, we will create a master docker-compose.yml file in the ~/ai-search directory.
version: '3.8'
networks:
ai-search-network:
driver: bridge
services:
searxng:
image: searxng/searxng:latest
container_name: searxng
volumes:
- ./searxng/settings.yml:/etc/searxng/settings.yml:ro
ports:
- "8080:8080"
networks:
- ai-search-network
restart: always
perplexica-backend:
image: perplexica-backend:latest
build:
context: ./Perplexica
dockerfile: backend.dockerfile
container_name: perplexica-backend
volumes:
- ./Perplexica/config.toml:/app/config.toml
ports:
- "3001:3001"
networks:
- ai-search-network
restart: always
perplexica-frontend:
image: perplexica-frontend:latest
build:
context: ./Perplexica
dockerfile: frontend.dockerfile
container_name: perplexica-frontend
ports:
- "3000:3000"
networks:
- ai-search-network
restart: alwaysLaunch the entire stack in detached mode using the following command:
docker-compose up -d --buildThe initial compilation and image building process may take several minutes depending on your VPS CPU performance. Once completed, verify that all three containers are actively running via docker ps.
Optimizing LLM Providers for a 2GB RAM Constraint
Because physical memory is severely restricted on a 2GB RAM VPS, running high-parameter local models via Ollama (such as Llama 3 or Mistral) on the same host will degrade response speeds or crash the system. The optimal strategy requires integrating cloud-hosted open-weights API endpoints.
We highly recommend utilizing Groq, Together AI, or OpenRouter. Groq, for instance, offers exceptionally high-throughput inference speeds for models like Llama 3 and Mixtral via an OpenAI-compatible API interface.
Configuring the Model via Perplexica UI
- Open your web browser and navigate to
http://your-vps-ip:3000to access the Perplexica frontend interface. - Click on the Settings gear icon located in the lower-left corner.
- Under the Model Provider dropdown, select your preferred provider (e.g., Groq).
- Input your corresponding API key generated from the provider's dashboard.
- Select a fast, context-optimized model such as
llama3-8b-8192ormixtral-8x7b-32768. - Save the settings. Your personal AI search engine is now fully functional and connected to live web streams.
Production Security and Reverse Proxy Integration
Exposing raw ports like 3000 and 8080 directly over the public internet exposes your infrastructure to malicious scanning and potential security exploits. In a production business environment, it is vital to secure the frontend with an Nginx Reverse Proxy and enforce SSL/TLS encryption via Let's Encrypt.
Nginx Configuration Example
Install Nginx on your host system and create a virtual host configuration file targeting your domain:
sudo apt install nginx -y
sudo nano /etc/nginx/sites-available/search.yourdomain.comInsert the reverse proxy directive routing traffic safely to the Perplexica frontend:
server {
listen 80;
server_name search.yourdomain.com;
location / {
proxy_pass [http://127.0.0.1:3000](http://127.0.0.1:3000);
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;
}
}Link the configuration to the enabled directory and apply SSL certification using Certbot:
sudo ln -s /etc/nginx/sites-available/search.yourdomain.com /etc/nginx/sites-enabled/
sudo systemctl restart nginx
sudo apt install certbot python3-certbot-nginx -y
sudo certbot --nginx -d search.yourdomain.com---Conclusion and Next Steps
Deploying a self-hosted AI search engine using Perplexica and SearXNG provides a masterclass in modern, efficient infrastructure engineering. By leveraging cloud APIs for heavy-lifting inference, you successfully run an incredibly sophisticated search platform on a highly economical 2GB RAM VPS without compromising response times or data privacy.
You now own a corporate-grade search pipeline that completely eliminates third-party user tracking, safeguards your proprietary analytical queries, and dramatically cuts down commercial software subscription overhead. As a next step, consider exploring Perplexica's specialized focus modes, such as Academic Mode or Writing Mode, to further optimize your professional research workflows.
