@@ -4,50 +4,64 @@
44Installation
55============
66
7−.. contents::
8− :depth: 3
7+.. sidebar:: Searx server setup
8+
9+ - :ref:`installation nginx`
10+ - :ref:`installation apache`
11+
12+ If you do not have any special preferences, it is recommend to use
13+ :ref:`searx.sh`.
14+
15+.. contents:: Contents
16+ :depth: 2
17+ :local:
18+ :backlinks: entry
919
1020.. _installation basic:
1121
1222Basic installation
1323==================
1424
15−.. sidebar:: further reading
25+Step by step installation with virtualenv. For Ubuntu, be sure to have enable
26+universe repository.
1627
17− - :ref:`searx.sh`
28+Install packages:
1829
19−Step by step installation for Debian/Ubuntu with virtualenv. For Ubuntu, be sure
20−to have enable universe repository.
30+.. tabs::
2131
22−Install packages:
32+ .. group-tab:: Ubuntu / debian
2333
24−.. code:: sh
34+ .. code-block:: sh
2535
26− $ sudo -H apt-get install \
27− git build-essential libxslt-dev \
28− python-dev python-virtualenv python-babel \
29− zlib1g-dev libffi-dev libssl-dev
36+ $ sudo -H apt-get install \
37+ git build-essential
38+ libxslt-dev python3-dev python3-babel \
39+ zlib1g-dev libffi-dev libssl-dev
3040
3141Install searx:
3242
3343.. code:: sh
3444
35− cd /usr/local
36− sudo -H git clone https://github.com/asciimoo/searx.git
37− sudo -H useradd searx -d /usr/local/searx
45+ sudo -H useradd searx --system --disabled-password -d /usr/local/searx
46+ sudo -H usermod -a -G shadow $SERVICE_USER
47+ cd /usr/local/searx
48+ sudo -H git clone https://github.com/asciimoo/searx.git searx-src
3849 sudo -H chown searx:searx -R /usr/local/searx
3950
40−Install dependencies in a virtualenv:
51+Install virtualenv:
4152
4253.. code:: sh
4354
44− cd /usr/local/searx
4555 sudo -H -u searx -i
56+ (searx)$ python3 -m venv searx-pyenv
57+ (searx)$ echo 'source ~/searx-pyenv/bin/activate' > ~/.profile
58+
59+Exit the searx bash and restart a new to install the searx dependencies:
4660
4761.. code:: sh
4862
49− (searx)$ virtualenv searx-ve
50− (searx)$ . ./searx-ve/bin/activate
63+ sudo -H -u searx -i
64+ (searx)$ cd searx-src
5165 (searx)$ ./manage.sh update_packages
5266
5367Configuration
@@ -55,7 +69,9 @@ Configuration
5569
5670.. code:: sh
5771
58− sed -i -e "s/ultrasecretkey/`openssl rand -hex 16`/g" searx/settings.yml
72+ sudo -H -u searx -i
73+ (searx)$ cd searx-src
74+ (searx)$ sed -i -e "s/ultrasecretkey/`openssl rand -hex 16`/g" searx/settings.yml
5975
6076Edit searx/settings.yml if necessary.
6177
@@ -66,7 +82,9 @@ Start searx:
6682
6783.. code:: sh
6884
69− python searx/webapp.py
85+ sudo -H -u searx -i
86+ (searx)$ cd searx-src
87+ (searx)$ python3 searx/webapp.py
7088
7189Go to http://localhost:8888
7290
@@ -76,254 +94,118 @@ If everything works fine, disable the debug option in settings.yml:
7694
7795 sed -i -e "s/debug : True/debug : False/g" searx/settings.yml
7896
79−At this point searx is not demonized ; uwsgi allows this.
80−
81−You can exit the virtualenv and the searx user bash (enter exit command
82−twice).
97+At this point searx is not demonized ; uwsgi allows this. You can exit the
98+virtualenv and the searx user bash (enter exit command twice).
8399
84100uwsgi
85101=====
86102
87103Install packages:
88104
89−.. code:: sh
90−
91− sudo -H apt-get install \
92− uwsgi uwsgi-plugin-python
93−
94−Create the configuration file ``/etc/uwsgi/apps-available/searx.ini`` with this
95−content:
96−
97−.. code:: ini
98−
99− [uwsgi]
100− # Who will run the code
101− uid = searx
102− gid = searx
103−
104− # disable logging for privacy
105− disable-logging = true
106−
107− # Number of workers (usually CPU count)
108− workers = 4
109−
110− # The right granted on the created socket
111− chmod-socket = 666
105+.. tabs::
112106
113− # Plugin to use and interpretor config
114− single-interpreter = true
115− master = true
116− plugin = python
117− lazy-apps = true
118− enable-threads = true
107+ .. group-tab:: Ubuntu / debian
119108
120− # Module to import
121− module = searx.webapp
109+ .. code-block:: bash
122110
123− # Support running the module from a webserver subdirectory.
124− route-run = fixpathinfo:
111+ sudo -H apt-get install uwsgi uwsgi-plugin-python3
125112
126− # Virtualenv and python path
127− virtualenv = /usr/local/searx/searx-ve/
128− pythonpath = /usr/local/searx/
129− chdir = /usr/local/searx/searx/
130−
131−Activate the uwsgi application and restart:
132−
133−.. code:: sh
134−
135− cd /etc/uwsgi/apps-enabled
136− ln -s ../apps-available/searx.ini
137− /etc/init.d/uwsgi restart
138−
139−Web server
140−==========
141−
142−with nginx
143−----------
144−
145−If nginx is not installed (uwsgi will not work with the package
146−nginx-light):
147−
148−.. code:: sh
149−
150− sudo -H apt-get install nginx
151−
152−Hosted at /
153−~~~~~~~~~~~
154−
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
156114content:
157115
158−.. code:: nginx
159−
160− server {
161− listen 80;
162− server_name searx.example.com;
163− root /usr/local/searx/searx;
164−
165− location /static {
166− }
167−
168− location / {
169− include uwsgi_params;
170− uwsgi_pass unix:/run/uwsgi/app/searx/socket;
171− }
172− }
173−
174−Create a symlink to sites-enabled:
175−
176−.. code:: sh
177−
178− sudo -H ln -s /etc/nginx/sites-available/searx /etc/nginx/sites-enabled/searx
179−
180−Restart service:
181−
182−.. code:: sh
183−
184− sudo -H service nginx restart
185− sudo -H service uwsgi restart
186−
187−from subdirectory URL (/searx)
188−~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
189−
190−Add this configuration in the server config file
191−``/etc/nginx/sites-enabled/default``:
192−
193−.. code:: nginx
194−
195− location /searx/static {
196− alias /usr/local/searx/searx/static;
197− }
198−
199− location /searx {
200− uwsgi_param SCRIPT_NAME /searx;
201− include uwsgi_params;
202− uwsgi_pass unix:/run/uwsgi/app/searx/socket;
203− }
204−
205−
206−**OR** using reverse proxy (Please, note that reverse proxy advised to be used
207−in case of single-user or low-traffic instances.)
208−
209−.. code:: nginx
210−
211− location /searx/static {
212− alias /usr/local/searx/searx/static;
213− }
214−
215− location /searx {
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;
222− }
223−
224−
225−Enable ``base_url`` in ``searx/settings.yml``
226−
227−.. code:: yaml
228−
229− base_url : http://your.domain.tld/searx/
116+.. code:: ini
230117
231−Restart service:
118+ [uwsgi]
232119
233−.. code:: sh
120+ # uWSGI core
121+ # ----------
122+ #
123+ # https://uwsgi-docs.readthedocs.io/en/latest/Options.html#uwsgi-core
234124
235− sudo -H service nginx restart
236− sudo -H service uwsgi restart
125+ # Who will run the code
126+ uid = searx
127+ gid = searx
237128
238−disable logs
239−^^^^^^^^^^^^
129+ # chdir to specified directory before apps loading
130+ chdir = /usr/local/searx/searx-src/searx
240131
241−for better privacy you can disable nginx logs about searx.
132+ # disable logging for privacy
133+ disable-logging = true
242134
243−how to proceed: below ``uwsgi_pass`` in ``/etc/nginx/sites-available/default``
244−add:
135+ # The right granted on the created socket
136+ chmod-socket = 666
245137
246−.. code:: nginx
138+ # Plugin to use and interpretor config
139+ single-interpreter = true
247140
248− access_log /dev/null;
249− error_log /dev/null;
141+ # enable master process
142+ master = true
250143
251−Restart service:
144+ # load apps in each worker instead of the master
145+ lazy-apps = true
252146
253−.. code:: sh
147+ # load uWSGI plugins
148+ plugin = python3,http
254149
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
256156
257−with apache
258−-----------
157+ # plugin: python
158+ # --------------
159+ #
160+ # https://uwsgi-docs.readthedocs.io/en/latest/Options.html#plugin-python
259161
260−Add wsgi mod:
162+ # load a WSGI module
163+ module = searx.webapp
261164
262−.. code:: sh
165+ # set PYTHONHOME/virtualenv
166+ virtualenv = /usr/local/searx/searx-pyenv
263167
264− sudo -H apt-get install libapache2-mod-uwsgi
265− sudo -H a2enmod uwsgi
168+ # add directory (or glob) to pythonpath
169+ pythonpath = /usr/local/searx/searx-src
266170
267−Add this configuration in the file ``/etc/apache2/apache2.conf``:
268171
269−.. code:: apache
172+ # plugin http
173+ # -----------
174+ #
175+ # https://uwsgi-docs.readthedocs.io/en/latest/Options.html#plugin-http
270176
271− <Location />
272− Options FollowSymLinks Indexes
273− SetHandler uwsgi-handler
274− uWSGISocket /run/uwsgi/app/searx/socket
275− </Location>
177+ # Native HTTP support: https://uwsgi-docs.readthedocs.io/en/latest/HTTP.html
178+ http = 127.0.0.1:8888
276179
277−Note that if your instance of searx is not at the root, you should change
278−``<Location />`` by the location of your instance, like ``<Location /searx>``.
279−
280−Restart Apache:
180+Activate the uwsgi application and restart:
281181
282182.. code:: sh
283183
284− sudo -H /etc/init.d/apache2 restart
285−
286−disable logs
287−~~~~~~~~~~~~
288−
289−For better privacy you can disable Apache logs.
290−
291−.. warning::
292−
293− You can only disable logs for the whole (virtual) server not for a specific
294− path.
295−
296−Go back to ``/etc/apache2/apache2.conf`` and above ``<Location />`` add:
297−
298−.. code:: apache
299−
300− CustomLog /dev/null combined
301−
302−Restart Apache:
303−
304−.. code:: sh
184+ cd /etc/uwsgi/apps-enabled
185+ ln -s ../apps-available/searx.ini
186+ /etc/init.d/uwsgi restart
305187
306− sudo -H /etc/init.d/apache2 restart
307188
308189How to update
309190=============
310191
311192.. code:: sh
312193
313− cd /usr/local/searx
314194 sudo -H -u searx -i
315−
316−.. code:: sh
317−
318− (searx)$ . ./searx-ve/bin/activate
319195 (searx)$ git stash
320196 (searx)$ git pull origin master
321197 (searx)$ git stash apply
322198 (searx)$ ./manage.sh update_packages
323199
324−.. code:: sh
200+Restart uwsgi:
201+
202+.. tabs::
203+
204+ .. group-tab:: Ubuntu / debian
205+
206+ .. code:: sh
325207
326− sudo -H service uwsgi restart
208+ sudo -H systemctl restart uwsgi
327209
328210Docker
329211======