Step by step installation

Step by step installation with virtualenv. For Ubuntu, be sure to have enable universe repository.

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

Hint

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 SearXNG & dependencies

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

$ sudo -H -u searx -i
(searx)$ git clone "https://github.com/searxng/searxng" "/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 SearXNG 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 SearXNG's working tree and install SearXNG 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

To create a initial /etc/searxng/settings.yml you can start with a copy of the file git://utils/templates/etc/searxng/settings.yml. This setup use default settings from git://searx/settings.yml.

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

$ sudo -H mkdir -p "/etc/searxng"
$ sudo -H cp "/usr/local/searx/searx-src/utils/templates/etc/searxng/settings.yml" \
             "/etc/searxng/settings.yml"
$ sudo -H sed -i -e "s/ultrasecretkey/$(openssl rand -hex 16)/g" "/etc/searxng/settings.yml"
# SearXNG settings, before editing this file read:
#
#     https://docs.searxng.org/admin/engines/settings.html

use_default_settings: true

general:
  # Debug mode, only for development
  debug: false
  # change displayed name
  # instance_name: "SearXNG"

search:
  # Filter results. 0: None, 1: Moderate, 2: Strict
  safe_search: 0
  # Existing autocomplete backends: "dbpedia", "duckduckgo", "google",
  # "startpage", "swisscows", "qwant", "wikipedia" - leave blank to turn it off
  # by default.
  autocomplete: ''
  # Default search language - leave blank to detect from browser information or
  # use codes from 'languages.py'
  default_lang: ''
  # remove format to deny access, use lower case.
  formats:
    - html

server:
  secret_key: "ultrasecretkey"  # change this!
  # Proxying image results through SearXNG
  image_proxy: false

# result_proxy:
#   url: http://127.0.0.1:3000/
#   key: !!binary "your_morty_proxy_key"

# plugins:
#   - only_show_green_results

# engines:
#
#   - name: duckduckgo
#     disabled: false
#
#   - name: fdroid
#     disabled: false
#
#   - name: apk mirror
#     disabled: false
#
#   - name: mediathekviewweb
#     engine: mediathekviewweb
#     shortcut: mvw
#     categories: general

Check

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

# enable debug ..
$ sudo -H sed -i -e "s/debug : False/debug : True/g" "/etc/searxng/settings.yml"

# start webapp
$ sudo -H -u searx -i
(searx)$ cd /usr/local/searx/searx-src
(searx)$ export SEARXNG_SETTINGS_PATH="/etc/searxng/settings.yml"
(searx)$ python searx/webapp.py

# disable debug
$ sudo -H sed -i -e "s/debug : True/debug : False/g" "/etc/searxng/settings.yml"

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

$ xdg-open http://127.0.0.1:8888

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