installation.rst 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355
  1. .. _installation:
  2. ============
  3. Installation
  4. ============
  5. .. contents::
  6. :depth: 3
  7. .. _installation basic:
  8. Basic installation
  9. ==================
  10. .. sidebar:: further reading
  11. - :ref:`searx.sh`
  12. Step by step installation for Debian/Ubuntu with virtualenv. For Ubuntu, be sure
  13. to have enable universe repository.
  14. Install packages:
  15. .. code:: sh
  16. $ sudo -H apt-get install \
  17. git build-essential libxslt-dev \
  18. python-dev python-virtualenv python-babel \
  19. zlib1g-dev libffi-dev libssl-dev
  20. Install searx:
  21. .. code:: sh
  22. cd /usr/local
  23. sudo -H git clone https://github.com/asciimoo/searx.git
  24. sudo -H useradd searx -d /usr/local/searx
  25. sudo -H chown searx:searx -R /usr/local/searx
  26. Install dependencies in a virtualenv:
  27. .. code:: sh
  28. cd /usr/local/searx
  29. sudo -H -u searx -i
  30. .. code:: sh
  31. (searx)$ virtualenv searx-ve
  32. (searx)$ . ./searx-ve/bin/activate
  33. (searx)$ ./manage.sh update_packages
  34. Configuration
  35. ==============
  36. .. code:: sh
  37. sed -i -e "s/ultrasecretkey/`openssl rand -hex 16`/g" searx/settings.yml
  38. Edit searx/settings.yml if necessary.
  39. Check
  40. =====
  41. Start searx:
  42. .. code:: sh
  43. python searx/webapp.py
  44. Go to http://localhost:8888
  45. If everything works fine, disable the debug option in settings.yml:
  46. .. code:: sh
  47. sed -i -e "s/debug : True/debug : False/g" searx/settings.yml
  48. At this point searx is not demonized ; uwsgi allows this.
  49. You can exit the virtualenv and the searx user bash (enter exit command
  50. twice).
  51. uwsgi
  52. =====
  53. Install packages:
  54. .. code:: sh
  55. sudo -H apt-get install \
  56. uwsgi uwsgi-plugin-python
  57. Create the configuration file ``/etc/uwsgi/apps-available/searx.ini`` with this
  58. content:
  59. .. code:: ini
  60. [uwsgi]
  61. # Who will run the code
  62. uid = searx
  63. gid = searx
  64. # disable logging for privacy
  65. disable-logging = true
  66. # Number of workers (usually CPU count)
  67. workers = 4
  68. # The right granted on the created socket
  69. chmod-socket = 666
  70. # Plugin to use and interpretor config
  71. single-interpreter = true
  72. master = true
  73. plugin = python
  74. lazy-apps = true
  75. enable-threads = true
  76. # Module to import
  77. module = searx.webapp
  78. # Support running the module from a webserver subdirectory.
  79. route-run = fixpathinfo:
  80. # Virtualenv and python path
  81. virtualenv = /usr/local/searx/searx-ve/
  82. pythonpath = /usr/local/searx/
  83. chdir = /usr/local/searx/searx/
  84. Activate the uwsgi application and restart:
  85. .. code:: sh
  86. cd /etc/uwsgi/apps-enabled
  87. ln -s ../apps-available/searx.ini
  88. /etc/init.d/uwsgi restart
  89. Web server
  90. ==========
  91. with nginx
  92. ----------
  93. If nginx is not installed (uwsgi will not work with the package
  94. nginx-light):
  95. .. code:: sh
  96. sudo -H apt-get install nginx
  97. Hosted at /
  98. ~~~~~~~~~~~
  99. Create the configuration file ``/etc/nginx/sites-available/searx`` with this
  100. content:
  101. .. code:: nginx
  102. server {
  103. listen 80;
  104. server_name searx.example.com;
  105. root /usr/local/searx/searx;
  106. location /static {
  107. }
  108. location / {
  109. include uwsgi_params;
  110. uwsgi_pass unix:/run/uwsgi/app/searx/socket;
  111. }
  112. }
  113. Create a symlink to sites-enabled:
  114. .. code:: sh
  115. sudo -H ln -s /etc/nginx/sites-available/searx /etc/nginx/sites-enabled/searx
  116. Restart service:
  117. .. code:: sh
  118. sudo -H service nginx restart
  119. sudo -H service uwsgi restart
  120. from subdirectory URL (/searx)
  121. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  122. Add this configuration in the server config file
  123. ``/etc/nginx/sites-enabled/default``:
  124. .. code:: nginx
  125. location /searx/static {
  126. alias /usr/local/searx/searx/static;
  127. }
  128. location /searx {
  129. uwsgi_param SCRIPT_NAME /searx;
  130. include uwsgi_params;
  131. uwsgi_pass unix:/run/uwsgi/app/searx/socket;
  132. }
  133. **OR** using reverse proxy (Please, note that reverse proxy advised to be used
  134. in case of single-user or low-traffic instances.)
  135. .. code:: nginx
  136. location /searx/static {
  137. alias /usr/local/searx/searx/static;
  138. }
  139. location /searx {
  140. proxy_pass http://127.0.0.1:8888;
  141. proxy_set_header Host $host;
  142. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  143. proxy_set_header X-Scheme $scheme;
  144. proxy_set_header X-Script-Name /searx;
  145. proxy_buffering off;
  146. }
  147. Enable ``base_url`` in ``searx/settings.yml``
  148. .. code:: yaml
  149. base_url : http://your.domain.tld/searx/
  150. Restart service:
  151. .. code:: sh
  152. sudo -H service nginx restart
  153. sudo -H service uwsgi restart
  154. disable logs
  155. ^^^^^^^^^^^^
  156. for better privacy you can disable nginx logs about searx.
  157. how to proceed: below ``uwsgi_pass`` in ``/etc/nginx/sites-available/default``
  158. add:
  159. .. code:: nginx
  160. access_log /dev/null;
  161. error_log /dev/null;
  162. Restart service:
  163. .. code:: sh
  164. sudo -H service nginx restart
  165. with apache
  166. -----------
  167. Add wsgi mod:
  168. .. code:: sh
  169. sudo -H apt-get install libapache2-mod-uwsgi
  170. sudo -H a2enmod uwsgi
  171. Add this configuration in the file ``/etc/apache2/apache2.conf``:
  172. .. code:: apache
  173. <Location />
  174. Options FollowSymLinks Indexes
  175. SetHandler uwsgi-handler
  176. uWSGISocket /run/uwsgi/app/searx/socket
  177. </Location>
  178. Note that if your instance of searx is not at the root, you should change
  179. ``<Location />`` by the location of your instance, like ``<Location /searx>``.
  180. Restart Apache:
  181. .. code:: sh
  182. sudo -H /etc/init.d/apache2 restart
  183. disable logs
  184. ~~~~~~~~~~~~
  185. For better privacy you can disable Apache logs.
  186. .. warning::
  187. You can only disable logs for the whole (virtual) server not for a specific
  188. path.
  189. Go back to ``/etc/apache2/apache2.conf`` and above ``<Location />`` add:
  190. .. code:: apache
  191. CustomLog /dev/null combined
  192. Restart Apache:
  193. .. code:: sh
  194. sudo -H /etc/init.d/apache2 restart
  195. How to update
  196. =============
  197. .. code:: sh
  198. cd /usr/local/searx
  199. sudo -H -u searx -i
  200. .. code:: sh
  201. (searx)$ . ./searx-ve/bin/activate
  202. (searx)$ git stash
  203. (searx)$ git pull origin master
  204. (searx)$ git stash apply
  205. (searx)$ ./manage.sh update_packages
  206. .. code:: sh
  207. sudo -H service uwsgi restart
  208. Docker
  209. ======
  210. Make sure you have installed Docker. For instance, you can deploy searx like this:
  211. .. code:: sh
  212. docker pull wonderfall/searx
  213. docker run -d --name searx -p $PORT:8888 wonderfall/searx
  214. Go to ``http://localhost:$PORT``.
  215. See https://hub.docker.com/r/wonderfall/searx/ for more informations. It's also
  216. possible to build searx from the embedded Dockerfile.
  217. .. code:: sh
  218. git clone https://github.com/asciimoo/searx.git
  219. cd searx
  220. docker build -t whatever/searx .
  221. References
  222. ==========
  223. * https://about.okhin.fr/posts/Searx/ with some additions
  224. * How to: `Setup searx in a couple of hours with a free SSL certificate
  225. <https://www.reddit.com/r/privacytoolsIO/comments/366kvn/how_to_setup_your_own_privacy_respecting_search/>`__