How to Install a Private Search Engine with Searx on Debian

Elderly woman using a DIY private search engine on a smartphone.

If you’ve ever complained about big search engines like Google and Bing logging your search activity and profiting from it, you’ve probably been greeted with the same sarcastic reply: “Ha, then why don’t you just create your own search engine?” The joke behind that reply is that it would be impractical to try to have your own search engine. Until now, that is.

Searx is an open source tool that gives you full control of your own private search engine. All you need is a private server and a little bit of command line judo to run through the installation process.

Make sure your business, agency, or reseller clients are always connected and powered on with our optimized Managed VPS Hosting.

Why Have a Private Search Engine?

Why would anyone want to create a private search engine? Here are a few reasons:

  • It’s secure
  • It’s free
  • It’s easy (well, easier than you might think)

It’s secure because your searches are not logged. When you use Searx to do a search, you get the same results you would get from Google, Bing, DuckDuckGo, or Yahoo. However, your search queries are totally private.

Please note: While your actual search query is private, your browsing activity (the websites you visit) is visible to your Internet Service Provider (ISP) or your network administrator. The only way to obfuscate your Internet browsing activity is to use a Virtual Private Network (VPN) service.

It’s free because Searx is open source technology you can install at no cost (except the minimal costs of maintaining your own server).

It’s easy to install Searx. All you need to do is log into your server via SSH and type in a few commands. It helps to have some knowledge of the Nginx web server you will be using to serve your search engine on the web.

It’s also a good idea to keep your search engine private to avoid high load on the server; you don’t want hundreds or thousands of people using your Searx instance at the same time as this will slow down your overall server performance. You can privatize your instance by installing it locally, or using the built-in Nginx IP deny function (which will be covered in this article).

How to Install Searx On Debian

The Searx installation is even simpler than in used to be. We recommend the Debian operation system for maximum simplicity. And, be sure to always double-check the Searx documentation for any changes in the installation process.

First you will need to install the search program itself. Start by downloading the files from GitHub:

cd ~/Downloads  &&
git clone https://github.com/searx/searx searx &&
cd searx

Install the Searx app:

sudo -H ./utils/searx.sh install all

Install the reverse proxy and result proxy:

sudo -H ./utils/filtron.sh install all &&
sudo -H ./utils/morty.sh install all

Next, install the Nginx web server. Bear in mind, your InMotion Hosting cloud server comes with Apache installed and running automatically, so first stop the Apache service and, optionally, remove it from your server:

sudo service apache2 stop

To remove Apache:

sudo apt remove apache2

Now, to install Nginx:

sudo apt install nginx

Check to make sure that your Nginx configurations are being loaded. Take a look at the /etc/nginx/nginx.conf file and make sure this line is present and not commented out:

include /etc/nginx/sites-enabled/*;

Create a configuration file for Searx here:

/etc/nginx/sites-enabled/searx

Now, how you want to configure your Nginx server is largely a matter of preference, but this basic configuration will work:

server {
  # replace hostname.local with your server's name
  server_name hostname.local;

  listen 80;
  listen [::]:80;

  location / {
      include uwsgi_params;
      uwsgi_pass unix:/run/uwsgi/app/searx/socket;
  }

  root /usr/local/searx/searx-src/searx;
  location /static { }
}

Make sure to replace “hostname.local” with the primary domain name of your cloud VPS server.

The Searx documentation recommends setting the following directory to make this configuration work properly:

mkdir -p /run/uwsgi/app/searx/  &&
sudo -H chown -R searx:searx /run/uwsgi/app/searx/

That’s about it. Again, if you want to customize the Nginx configuration differently, be sure to check the Searx documentation for alternative examples you can plug and play.

Otherwise, you should now be able to load your domain and see the Searx landing page with search bar. Try out the search feature and you’ll be amazed at what you see. You now have your own search engine running on your private server.

Deny/Allow IP Addresses With Nginx

Nginx allows you to put some directives in your configuration file that dictate what IP addresses, or address ranges, are permitted to view the site. All others will receive a default 403 error.

Add these lines to your server {} block:

allow 1.2.3.4;
deny all;

Of course, replace 1.2.3.4 with the valid IP address of your choice.

Some Next Steps

If you’d like to learn more about the operating system used for this article, check out our full guide on the pros and cons of the Debian operating system.

Likewise, you can check out the entire VPS hosting product guide to further immerse yourself in learning resources.

CM
Christopher Maiorana Content Writer II

Christopher Maiorana joined the InMotion community team in 2015 and regularly dispenses tips and tricks in the Support Center, Community Q&A, and the InMotion Hosting Blog.

More Articles by Christopher

Was this article helpful? Join the conversation!