Self-Hosting a Perplexity Alternative: Deploying AI Search with Perplexica and SearXNG on a 2-Core VPS
Introduction: The Shift Toward Sovereignty in AI Search
AI-powered search engines like Perplexity AI have fundamentally changed how we research, synthesize, and consume information online. By replacing traditional list-of-links search results with conversational, context-aware answers backed by real-time citations, these platforms offer immense productivity gains. However, relying entirely on proprietary, cloud-hosted AI search models introduces significant challenges, particularly regarding data privacy, vendor lock-in, and unpredictable subscription costs.
For businesses, developers, and privacy enthusiasts, the solution lies in self-hosting. Thanks to the rapid evolution of the open-source ecosystem, you can now deploy a robust, private alternative using Perplexica and SearXNG. Best of all, you do not need expensive enterprise hardware; a modest, budget-friendly 2-Core VPS (Virtual Private Server) is more than capable of running this stack smoothly. This guide provides a step-by-step blueprint to setting up your own AI search engine from scratch.
---Understanding the Architecture: Perplexica and SearXNG
Before diving into the technical installation, it is crucial to understand how the components interact to deliver a seamless AI search experience. Our self-hosted setup relies on two core pillars:
- SearXNG: A privacy-respecting, open-source metasearch engine. Instead of scraping the web directly, SearXNG aggregates search results from over 70 different search engines (including Google, Bing, and DuckDuckGo) while completely stripping out tracking cookies, profiling data, and advertisements.
- Perplexica: The brain of the operation. It acts as an open-source AI-powered search engine wrapper that takes your query, uses SearXNG to fetch the latest relevant web data, and passes that context into a Large Language Model (LLM) to generate a coherent, cited answer.
By decoupling the web search mechanism (SearXNG) from the reasoning mechanism (Perplexica), this architecture allows for incredible flexibility. You can connect Perplexica to local LLMs via Ollama to keep 100% of the data on your server, or connect to cost-effective, high-speed cloud APIs like OpenAI, Anthropic, or Groq for blazing-fast inference.
---Prerequisites and Hardware Optimization
While Perplexica can scale up significantly, a 2-Core VPS with 4GB of RAM is the ideal sweet spot for individual use or small team deployments, provided you offload the heavy LLM inference to an external API (like Groq or OpenAI). If you intend to run LLMs locally on the same machine using Ollama, you will need a significantly larger VPS with a dedicated GPU.
Minimum Requirements for an API-Driven Setup:
- CPU: 2 vCPU Cores
- RAM: 4GB (Minimum 2GB, but 4GB ensures stability under concurrent queries)
- Storage: 20GB SSD / NVMe
- OS: Ubuntu 22.04 LTS or Ubuntu 24.04 LTS
- Network: Public IP address with ports 80 and 443 open
Step 1: Preparing Your VPS Environment
Connect to your VPS via SSH and begin by updating the system packages to ensure all security patches are current:
sudo apt update && sudo apt upgrade -y
Next, install the essential dependencies required to run containerized applications. We will use Docker and Docker Compose to orchestrate our services, making deployment and future updates seamless.
sudo apt install -y curl git secure-delete jq
curl -fsSL [https://get.docker.com](https://get.docker.com) -o get-docker.sh
sudo sh get-docker.sh
Verify that Docker is installed and running correctly:
docker --version && docker compose version---
Step 2: Deploying and Configuring SearXNG
Perplexica relies on SearXNG to fetch web context. To avoid potential IP blocks from public search engines, we must configure SearXNG carefully. Create a dedicated directory for your AI search stack and clone a highly optimized SearXNG configuration:
mkdir -p ~/ai-search && cd ~/ai-search
git clone [https://github.com/searxng/searxng-docker.git](https://github.com/searxng/searxng-docker.git) searxng
cd searxng
Before launching, we need to generate a secure secret key for SearXNG's internal session management. Run the following command to alter the configuration file dynamically:
sed -i "s|ultrasecretkey|$(openssl rand -hex 32)|g" searxng/settings.yml
Open the searxng/settings.yml file using your preferred text editor (e.g., nano) to ensure the output format includes JSON, which Perplexica requires to parse results:
formats:
- html
- json
Launch the SearXNG container cluster in detached mode:
docker compose up -d---
Step 3: Installing and Configuring Perplexica
With our metasearch engine live, navigate back to your root project directory to pull and configure Perplexica:
cd ~/ai-search
git clone [https://github.com/ItzCrazyK0S/Perplexica.git](https://github.com/ItzCrazyK0S/Perplexica.git) perplexica
cd perplexica
Perplexica comes with an interactive setup wizard that simplifies configuration. Rename the sample environment file and run the setup script:
cp sample.config.toml config.toml
nano config.toml
Within the config.toml file, you need to map out your API endpoints and specify your SearXNG URL. Update the following key fields:
- SEARXNG_URL: Change this to pointing to your local SearXNG container instance, typically
http://searxng:8080within the Docker network. - LLM_PROVIDER: Choose your provider (e.g.,
openai,groq, oranthropic). For a 2-Core VPS, using Groq is highly recommended due to its extreme speed and low latency. - LLM_MODEL: Specify the model you wish to use (e.g.,
llama3-70b-8192on Groq orgpt-4o-minion OpenAI).
Once your configuration is saved, build and launch the Perplexica frontend and backend containers:
docker compose up --build -d---
Step 4: Securing Your AI Search Platform with Nginx
Running your application over unencrypted HTTP exposes your API keys and queries to interception. To protect your server, we will use Nginx as a reverse proxy and Let's Encrypt to provision a free, automated SSL certificate.
sudo apt install -y nginx certbot python3-certbot-nginx
Create a new Nginx server block configuration for your domain (e.g., search.yourdomain.com):
sudo nano /etc/nginx/sites-available/perplexica
Paste the following structural configuration, directing incoming traffic to Perplexica’s web UI port (typically 3000):
server {
listen 80;
server_name search.yourdomain.com;
location / {
proxy_pass http://localhost: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;
}
}
Enable the site configuration and reload Nginx:
sudo ln -s /etc/nginx/sites-available/perplexica /etc/nginx/sites-enabled/
sudo systemctl reload nginx
Finally, secure your domain with an SSL certificate using Certbot:
sudo certbot --nginx -d search.yourdomain.com---
Conclusion: Complete Control Over Your Knowledge Discovery
By following this guide, you have effectively liberated your search workflows from commercial constraints. You now possess a highly responsive, custom-tailored Perplexity alternative powered by Perplexica and SearXNG running entirely on your own cost-effective VPS. This setup guarantees that your search queries remain strictly private, your data feeds are unmanipulated by commercial ad networks, and your operations stay agile. As the open-source AI space moves forward, your self-hosted infrastructure is ready to adapt, scale, and evolve alongside it.
