How to Self-Host SearXNG on a VPS (Complete Guide)
SearXNG is an open-source metasearch engine that allows users to search the web anonymously. Self-hosting it on a VPS is a practical solution for developers and tech enthusiasts looking to gain control over their search data. In this guide, weโll walk you through the process of setting up SearXNG on various VPS providers, including installation steps and configuration tips.
Choosing a VPS Provider
Before you start, youโll need a suitable VPS. Hereโs a comparison of some top VPS providers ideal for hosting SearXNG:
| Provider | Monthly Price | RAM | CPU | Disk Space |
|---|---|---|---|---|
| Contabo VPS | 5.99 EUR | 4 GB | 2 | 300 GB SSD |
| Hetzner Cloud | 4.15 EUR | 2 GB | 1 | 20 GB SSD |
| DigitalOcean | 6 USD | 1 GB | 1 | 25 GB SSD |
| Vultr | 6 USD | 1 GB | 1 | 25 GB SSD |
| Linode | 5 USD | 2 GB | 1 | 25 GB SSD |
For self-hosting SearXNG, consider a VPS with at least 1 GB of RAM. Although all options listed can serve, the Contabo VPS offers a solid performance-to-cost ratio.
Prerequisites for Installation
- VPS Setup: Obtain a VPS from your chosen provider. You can explore a full VPS comparison to find the best fit for your needs.
- Domain Name: Optional, but recommended for easier access.
- Basic Knowledge: Familiarity with Linux, Docker, and command-line operations.
Step 1: Access Your VPS
Once your VPS is set up, log in through SSH using the terminal:
ssh root@your_vps_ip
Replace your_vps_ip with your actual VPS IP address.
Step 2: Install Docker
To run SearXNG, you will need Docker. Install it by following these commands:
apt update
apt install -y apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/debian/gpg | apt-key add -
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable"
apt update
apt install -y docker-ce
Confirm Docker is running:
systemctl status docker
Step 3: Install Docker Compose
Docker Compose simplifies multi-container Docker applications. Install it using:
curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
Verify the installation:
docker-compose --version
Step 4: Download SearXNG
Create a directory for SearXNG and move into it:
mkdir /opt/searxng
cd /opt/searxng
Download the SearXNG source code:
git clone https://github.com/searxng/searxng.git .
Step 5: Configure Environment Variables
Create a local configuration file:
cp .env.sample .env
Edit the .env file to customize SearXNG settings, choosing your preferred search engines and the secret key.
Step 6: Run SearXNG with Docker Compose
Create a docker-compose.yml file in the /opt/searxng directory, specifying the services required:
version: '3'
services:
searxng:
image: searxng/searxng:latest
container_name: searxng
ports:
- "8080:8080"
volumes:
- searxng_data:/usr/src/searxng/searxng/data
restart: unless-stopped
volumes:
searxng_data:
Now you can start SearXNG:
docker-compose up -d
Step 7: Access SearXNG
Once SearXNG is running, access it through your web browser by visiting http://your_vps_ip:8080.
Common Issues and Troubleshooting
If you encounter issues during installation, check the following:
- Ensure Docker is running.
- Validate the
.envconfigurations. - Inspect logs using:
docker-compose logs
FAQs
1. Can I use SearXNG without a domain?
Yes, SearXNG can be accessed directly through the VPS IP address. However, using a domain name enhances usability, as it allows easier access and can make the service feel more professional.
2. What should I do if the application doesnโt load?
Ensure the Docker service is running correctly, and check the firewall settings on your VPS. You can also verify Docker logs for any errors by running docker-compose logs in the SearXNG directory to troubleshoot ongoing issues.
3. How often should I update SearXNG?
Itโs a good practice to regularly check for updates or new releases from the SearXNG repository. Maintaining up-to-date software can ensure that you benefit from the latest features, security patches, and improvements. You can update SearXNG using git pull followed by docker-compose up -d to apply changes.
By following this guide, youโll be able to successfully self-host SearXNG on your preferred VPS provider. Enjoy anonymous searching while maintaining control over your data.