@@ -4,50 +4,64 @@
4Installation
4Installation
5============
5============
7+.. sidebar:: Searx server setup
9+ - :ref:`installation nginx`
10+ - :ref:`installation apache`
12+ If you do not have any special preferences, it is recommend to use
7−.. contents::
15+.. contents:: Contents
8− :depth: 3
16+ :depth: 2
10.. _installation basic:
20.. _installation basic:
12Basic installation
22Basic installation
13==================
23==================
15−.. sidebar:: further reading
25+Step by step installation with virtualenv. For Ubuntu, be sure to have enable
17− - :ref:`searx.sh`
28+Install packages:
19−Step by step installation for Debian/Ubuntu with virtualenv. For Ubuntu, be sure
30+.. tabs::
20−to have enable universe repository.
22−Install packages:
32+ .. group-tab:: Ubuntu / debian
24−.. code:: sh
34+ .. code-block:: sh
26− $ sudo -H apt-get install \
36+ $ sudo -H apt-get install \
27− git build-essential libxslt-dev \
37+ git build-essential
28− python-dev python-virtualenv python-babel \
38+ libxslt-dev python3-dev python3-babel \
29− zlib1g-dev libffi-dev libssl-dev
39+ zlib1g-dev libffi-dev libssl-dev
31Install searx:
41Install searx:
33.. code:: sh
43.. code:: sh
45+ sudo -H useradd searx --system --disabled-password -d /usr/local/searx
46+ sudo -H usermod -a -G shadow $SERVICE_USER
35− cd /usr/local
47+ cd /usr/local/searx
36− sudo -H git clone https://github.com/asciimoo/searx.git
48+ sudo -H git clone https://github.com/asciimoo/searx.git searx-src
37− sudo -H useradd searx -d /usr/local/searx
38 sudo -H chown searx:searx -R /usr/local/searx
49 sudo -H chown searx:searx -R /usr/local/searx
40−Install dependencies in a virtualenv:
51+Install virtualenv:
42.. code:: sh
53.. code:: sh
45 sudo -H -u searx -i
55 sudo -H -u searx -i
56+ (searx)$ python3 -m venv searx-pyenv
57+ (searx)$ echo 'source ~/searx-pyenv/bin/activate' > ~/.profile
59+Exit the searx bash and restart a new to install the searx dependencies:
47.. code:: sh
61.. code:: sh
49− (searx)$ virtualenv searx-ve
63+ sudo -H -u searx -i
50− (searx)$ . ./searx-ve/bin/activate
64+ (searx)$ cd searx-src
51 (searx)$ ./manage.sh update_packages
65 (searx)$ ./manage.sh update_packages
53Configuration
67Configuration
@@ -55,7 +69,9 @@ Configuration
56.. code:: sh
70.. code:: sh
73+ (searx)$ cd searx-src
58− sed -i -e "s/ultrasecretkey/`openssl rand -hex 16`/g" searx/settings.yml
74+ (searx)$ sed -i -e "s/ultrasecretkey/`openssl rand -hex 16`/g" searx/settings.yml
60Edit searx/settings.yml if necessary.
76Edit searx/settings.yml if necessary.
@@ -66,7 +82,9 @@ Start searx:
67.. code:: sh
83.. code:: sh
86+ (searx)$ cd searx-src
69− python searx/webapp.py
87+ (searx)$ python3 searx/webapp.py
71Go to http://localhost:8888
89Go to http://localhost:8888
@@ -76,254 +94,118 @@ If everything works fine, disable the debug option in settings.yml:
77 sed -i -e "s/debug : True/debug : False/g" searx/settings.yml
95 sed -i -e "s/debug : True/debug : False/g" searx/settings.yml
79−At this point searx is not demonized ; uwsgi allows this.
97+At this point searx is not demonized ; uwsgi allows this. You can exit the
81−You can exit the virtualenv and the searx user bash (enter exit command
98+virtualenv and the searx user bash (enter exit command twice).
87Install packages:
103Install packages:
89−.. code:: sh
105+.. tabs::
91− sudo -H apt-get install \
92− uwsgi uwsgi-plugin-python
94−Create the configuration file ``/etc/uwsgi/apps-available/searx.ini`` with this
100− # Who will run the code
104− # disable logging for privacy
105− disable-logging = true
107− # Number of workers (usually CPU count)
110− # The right granted on the created socket
113− # Plugin to use and interpretor config
107+ .. group-tab:: Ubuntu / debian
114− single-interpreter = true
118− enable-threads = true
120− # Module to import
109+ .. code-block:: bash
121− module = searx.webapp
123− # Support running the module from a webserver subdirectory.
111+ sudo -H apt-get install uwsgi uwsgi-plugin-python3
124− route-run = fixpathinfo:
126− # Virtualenv and python path
127− virtualenv = /usr/local/searx/searx-ve/
128− pythonpath = /usr/local/searx/
129− chdir = /usr/local/searx/searx/
131−Activate the uwsgi application and restart:
135− cd /etc/uwsgi/apps-enabled
136− ln -s ../apps-available/searx.ini
137− /etc/init.d/uwsgi restart
145−If nginx is not installed (uwsgi will not work with the package
150− sudo -H apt-get install nginx
155−Create the configuration file ``/etc/nginx/sites-available/searx`` with this
113+Create the configuration file ``/etc/uwsgi/apps-available/searx.ini`` with this
158−.. code:: nginx
116+.. code:: ini
162− server_name searx.example.com;
163− root /usr/local/searx/searx;
169− include uwsgi_params;
170− uwsgi_pass unix:/run/uwsgi/app/searx/socket;
174−Create a symlink to sites-enabled:
178− sudo -H ln -s /etc/nginx/sites-available/searx /etc/nginx/sites-enabled/searx
184− sudo -H service nginx restart
185− sudo -H service uwsgi restart
187−from subdirectory URL (/searx)
188−~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
190−Add this configuration in the server config file
191−``/etc/nginx/sites-enabled/default``:
195− location /searx/static {
196− alias /usr/local/searx/searx/static;
200− uwsgi_param SCRIPT_NAME /searx;
201− include uwsgi_params;
202− uwsgi_pass unix:/run/uwsgi/app/searx/socket;
206−**OR** using reverse proxy (Please, note that reverse proxy advised to be used
207−in case of single-user or low-traffic instances.)
211− location /searx/static {
212− alias /usr/local/searx/searx/static;
216− proxy_pass http://127.0.0.1:8888;
217− proxy_set_header Host $host;
218− proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
219− proxy_set_header X-Scheme $scheme;
220− proxy_set_header X-Script-Name /searx;
221− proxy_buffering off;
225−Enable ``base_url`` in ``searx/settings.yml``
229− base_url : http://your.domain.tld/searx/
231−Restart service:
118+ [uwsgi]
233−.. code:: sh
120+ # uWSGI core
123+ # https://uwsgi-docs.readthedocs.io/en/latest/Options.html#uwsgi-core
235− sudo -H service nginx restart
125+ # Who will run the code
236− sudo -H service uwsgi restart
126+ uid = searx
238−disable logs
129+ # chdir to specified directory before apps loading
239−^^^^^^^^^^^^
130+ chdir = /usr/local/searx/searx-src/searx
241−for better privacy you can disable nginx logs about searx.
132+ # disable logging for privacy
133+ disable-logging = true
243−how to proceed: below ``uwsgi_pass`` in ``/etc/nginx/sites-available/default``
135+ # The right granted on the created socket
244−add:
136+ chmod-socket = 666
246−.. code:: nginx
138+ # Plugin to use and interpretor config
139+ single-interpreter = true
248− access_log /dev/null;
141+ # enable master process
249− error_log /dev/null;
142+ master = true
251−Restart service:
144+ # load apps in each worker instead of the master
253−.. code:: sh
147+ # load uWSGI plugins
148+ plugin = python3,http
255− sudo -H service nginx restart
150+ # By default the Python plugin does not initialize the GIL. This means your
151+ # app-generated threads will not run. If you need threads, remember to enable
152+ # them with enable-threads. Running uWSGI in multithreading mode (with the
153+ # threads options) will automatically enable threading support. This *strange*
154+ # default behaviour is for performance reasons.
155+ enable-threads = true
257−with apache
157+ # plugin: python
258−-----------
158+ # --------------
160+ # https://uwsgi-docs.readthedocs.io/en/latest/Options.html#plugin-python
260−Add wsgi mod:
162+ # load a WSGI module
163+ module = searx.webapp
262−.. code:: sh
165+ # set PYTHONHOME/virtualenv
166+ virtualenv = /usr/local/searx/searx-pyenv
264− sudo -H apt-get install libapache2-mod-uwsgi
168+ # add directory (or glob) to pythonpath
265− sudo -H a2enmod uwsgi
169+ pythonpath = /usr/local/searx/searx-src
267−Add this configuration in the file ``/etc/apache2/apache2.conf``:
269−.. code:: apache
172+ # plugin http
175+ # https://uwsgi-docs.readthedocs.io/en/latest/Options.html#plugin-http
271− <Location />
177+ # Native HTTP support: https://uwsgi-docs.readthedocs.io/en/latest/HTTP.html
272− Options FollowSymLinks Indexes
178+ http = 127.0.0.1:8888
273− SetHandler uwsgi-handler
274− uWSGISocket /run/uwsgi/app/searx/socket
277−Note that if your instance of searx is not at the root, you should change
180+Activate the uwsgi application and restart:
278−``<Location />`` by the location of your instance, like ``<Location /searx>``.
282.. code:: sh
182.. code:: sh
184+ cd /etc/uwsgi/apps-enabled
185+ ln -s ../apps-available/searx.ini
284− sudo -H /etc/init.d/apache2 restart
186+ /etc/init.d/uwsgi restart
289−For better privacy you can disable Apache logs.
293− You can only disable logs for the whole (virtual) server not for a specific
296−Go back to ``/etc/apache2/apache2.conf`` and above ``<Location />`` add:
300− CustomLog /dev/null combined
306− sudo -H /etc/init.d/apache2 restart
308How to update
189How to update
309=============
190=============
311.. code:: sh
192.. code:: sh
314 sudo -H -u searx -i
194 sudo -H -u searx -i
318− (searx)$ . ./searx-ve/bin/activate
319 (searx)$ git stash
195 (searx)$ git stash
320 (searx)$ git pull origin master
196 (searx)$ git pull origin master
321 (searx)$ git stash apply
197 (searx)$ git stash apply
322 (searx)$ ./manage.sh update_packages
198 (searx)$ ./manage.sh update_packages
204+ .. group-tab:: Ubuntu / debian
324−.. code:: sh
206+ .. code:: sh
326− sudo -H service uwsgi restart
208+ sudo -H systemctl restart uwsgi