How to Install Searx Search Engine on Ubuntu / debianArch LinuxFedora / RHEL

RomanAcademy
3 min readNov 25, 2022

--

How to Install Searx Search Engine on Ubuntu / debianArch LinuxFedora / RHEL

Install packages

$ sudo -H apt-get install -y \
python3-dev python3-babel python3-venv \
uwsgi uwsgi-plugin-python3 \
git build-essential libxslt-dev zlib1g-dev libffi-dev libssl-dev \
shellcheck

This installs also the packages needed by uwsgi

Create user

$ sudo -H useradd --shell /bin/bash --system \
--home-dir "/usr/local/searx" \
--comment 'Privacy-respecting metasearch engine' searx
$ sudo -H mkdir "/usr/local/searx"
$ sudo -H chown -R "searx:searx" "/usr/local/searx"

Install searx & dependencies

Start a interactive shell from new created user and clone searx:

$ sudo -H -u searx -i
(searx)$ git clone "https://github.com/searx/searx.git" "/usr/local/searx/searx-src"

In the same shell create virtualenv:

(searx)$ python3 -m venv "/usr/local/searx/searx-pyenv"
(searx)$ echo ". /usr/local/searx/searx-pyenv/bin/activate" >> "/usr/local/searx/.profile"

To install searx’s dependencies, exit the searx bash session you opened above and restart a new. Before install, first check if your virtualenv was sourced from the login (~/.profile):

$ sudo -H -u searx -i
(searx)$ command -v python && python --version
/usr/local/searx/searx-pyenv/bin/python
Python 3.8.1
# update pip's boilerplate ..
pip install -U pip
pip install -U setuptools
pip install -U wheel
pip install -U pyyaml
# jump to searx's working tree and install searx into virtualenv
(searx)$ cd "/usr/local/searx/searx-src"
(searx)$ pip install -e .

Tip

Open a second terminal for the configuration tasks and leave the (searx)$ terminal open for the tasks below.

Configuration

use_default_settings: True

To create a initial /etc/searx/settings.yml you can start with a copy of the file Origin: utils/templates/etc/searx/use_default_settings.yml. This setup use default settings from Origin: searx/settings.yml and is recommended since PR 2291 is merged.

For a minimal setup, configure like shown below — replace searx@$(uname -n) with a name of your choice, set ultrasecretkeyand/or edit /etc/searx/settings.yml to your needs.

Use default settingssearx/settings.yml

$ sudo -H mkdir -p "/etc/searx"
$ sudo -H cp "/usr/local/searx/searx-src/utils/templates/etc/searx/use_default_settings.yml" \
"/etc/searx/settings.yml"

minimal setup

$ sudo -H sed -i -e "s/ultrasecretkey/$(openssl rand -hex 16)/g" "/etc/searx/settings.yml"
$ sudo -H sed -i -e "s/{instance_name}/searx@$(uname -n)/g" "/etc/searx/settings.yml"

Use default settingssearx/settings.yml

use_default_settings: True
general:
debug : False # Debug mode, only for development
instance_name : "searx" # displayed name
search:
safe_search : 0 # Filter results. 0: None, 1: Moderate, 2: Strict
autocomplete : "" # Existing autocomplete backends: "dbpedia", "duckduckgo", "google", "startpage", "swisscows", "qwant", "wikipedia" - leave blank to turn it off by default
default_lang : "" # Default search language - leave blank to detect from browser information or use codes from 'languages.py'
server:
port : 8888
bind_address : "127.0.0.1" # address to listen on
secret_key : "ultrasecretkey" # change this!
base_url : False # Set custom base_url. Possible values: False or "https://your.custom.host/location/"
image_proxy : False # Proxying image results through searx
# uncomment below section if you have running morty proxy
#result_proxy:
# url : http://127.0.0.1:3000/
# key : !!binary "your_morty_proxy_key"

Check

To check your searx setup, optional enable debugging and start the webapp. Searx looks at the exported environment $SEARX_SETTINGS_PATH for a configuration file.

# enable debug ..
$ sudo -H sed -i -e "s/debug : False/debug : True/g" "/etc/searx/settings.yml"
# start webapp
$ sudo -H -u searx -i
(searx)$ cd /usr/local/searx/searx-src
(searx)$ export SEARX_SETTINGS_PATH="/etc/searx/settings.yml"
(searx)$ python searx/webapp.py
# disable debug
$ sudo -H sed -i -e "s/debug : True/debug : False/g" "/etc/searx/settings.yml"

Open WEB browser and visit http:// . If you are inside a container or in a script, test with curl:

WEB browsercurl

$ xdg-open http://

If everything works fine, hit [CTRL-C] to stop the webapp and disable the debug option in settings.yml. You can now exit searx user bash (enter exit command twice). At this point searx is not demonized; uwsgi allows this.

--

--

RomanAcademy
RomanAcademy

Written by RomanAcademy

If software and web development are something you’re interested in, you’ll find a lot of helpful information on this channel.

No responses yet