Simple install for Searx on Ubuntu with Apache

Hosting your own instance of Searx is pretty straight forward. Tutorials I've read are not that complex, but somehow none of them got me all the way on a clean Ubuntu 18.04 LTS install. There is how I went about it.

A bunch of dependencies need to be installed. 

sudo apt-get install git build-essential python-babel zlib1g-dev libffi-dev libssl-dev libxslt-dev python-dev python-virtualenv -y

Select a folder where to clone the repository. I chose /opt.

cd /opt
sudo git clone https://github.com/asciimoo/searx.git
cd searx

Inside this directory, there is another folder called 'searx'. Inside is a settings file called 'settings.yml'.

The 'official' documentation suggests creating a secret key with the following command.

sed -i -e "s/ultrasecretkey/`openssl rand -hex 16`/g" searx/settings.yml

Next up is using virtualenv to install the dependencies in a virtual environment. I needed to install it first.

sudo apt-get install virtualenv

Then use the following commands.

sudo virtualenv searx-ve
source searx-ve/bin/activate
./manage.sh update_packages

If all dependencies were properly installed, Searx can be started by calling webapp.py.

sudo python searx/webapp.py

This should start Searx on the default port 8888. 

Now, in order to properly use it from your browser, we need a web server configuration. In my case, I went for Apache.

sudo apt-get install apache2

To configure Apache, add a configuration (.conf file) in /etc/apache2/sites-enabled (or add it to sites-available and create a sim link in sites-enabled). Add the following virtual host configuration to the file:

<VirtualHost *:80>
ProxyPreserveHost On
ProxyPass "/" "http://127.0.0.1:8888/"
ProxyPassReverse "/" "http://127.0.0.1:8888/"
ServerName your-domain.com
</VirtualHost>

Replace 'your-domain.com' with the domain name you will use for your Searx instance. 

Before starting Apache, be sure to enable a few mods:

a2enmod proxy
a2enmod proxy_http

I also enabled the following, though I do not believe they are required with the current simple configuration:

a2enmod lbmethod_byrequests
a2enmod proxy_html

When restarting Apache, you should see the Searx search page when navigating to the domain entered in the configuration.

Note: Be sure to also configure an SSL certificate, for example with Letsencrypt

 Sources: