Step by step installation

In this section we show the setup of a SearXNG instance that will be installed by the Installation Script.

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

Hint

This installs also the packages needed by uWSGI

Create user

$ sudo -H useradd --shell /bin/bash --system \
    --home-dir "/usr/local/searxng" \
    --comment 'Privacy-respecting metasearch engine' \
    searxng

$ sudo -H mkdir "/usr/local/searxng"
$ sudo -H chown -R "searxng:searxng" "/usr/local/searxng"

Install SearXNG & dependencies

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

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

In the same shell create virtualenv:

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

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

$ sudo -H -u searxng -i

(searxng)$ command -v python && python --version
/usr/local/searxng/searx-pyenv/bin/python
Python 3.11.10

# 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
(searxng)$ cd "/usr/local/searxng/searxng-src"
(searxng)$ pip install --use-pep517 --no-build-isolation -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 we recommend to start with a copy of the file git://utils/templates/etc/searxng/settings.yml. This setup use default settings from git://searx/settings.yml and is shown in the tab “Use default settings” below. This setup:

Modify the /etc/searxng/settings.yml to your needs:

# SearXNG settings

use_default_settings: true

general:
  debug: false
  instance_name: "SearXNG"

search:
  safe_search: 2
  autocomplete: 'duckduckgo'

server:
  # Is overwritten by ${SEARXNG_SECRET}
  secret_key: "ultrasecretkey"
  limiter: true
  image_proxy: true
  # public URL of the instance, to ensure correct inbound links. Is overwritten
  # by ${SEARXNG_URL}.
  # base_url: http://example.com/location

redis:
  # URL to connect redis database. Is overwritten by ${SEARXNG_REDIS_URL}.
  url: unix:///usr/local/searxng-redis/run/redis.sock?db=0

ui:
  static_use_hash: true

# preferences:
#   lock:
#     - autocomplete
#     - method

enabled_plugins:
  - 'Hash plugin'
  - 'Self Informations'
  - 'Tracker URL remover'
  - 'Ahmia blacklist'
  # - 'Hostnames plugin'  # see 'hostnames' configuration below
  # - 'Open Access DOI rewrite'

# plugins:
#   - only_show_green_results

To see the entire file jump to git://utils/templates/etc/searxng/settings.yml

For a minimal setup you need to set server:secret_key.

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

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 searxng -i
(searxng)$ cd /usr/local/searxng/searxng-src
(searxng)$ export SEARXNG_SETTINGS_PATH="/etc/searxng/settings.yml"
(searxng)$ 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 session (enter exit command twice). At this point SearXNG is not demonized; uwsgi allows this.