installation.rst 6.6 KB

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