installation.rst 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349
  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/searx;
  103. location /static {
  104. }
  105. location / {
  106. include uwsgi_params;
  107. uwsgi_pass unix:/run/uwsgi/app/searx/socket;
  108. }
  109. }
  110. Create a symlink to sites-enabled:
  111. .. code:: sh
  112. sudo -H ln -s /etc/nginx/sites-available/searx /etc/nginx/sites-enabled/searx
  113. Restart service:
  114. .. code:: sh
  115. sudo -H service nginx restart
  116. sudo -H service uwsgi restart
  117. from subdirectory URL (/searx)
  118. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  119. Add this configuration in the server config file
  120. ``/etc/nginx/sites-enabled/default``:
  121. .. code:: nginx
  122. location /searx/static {
  123. alias /usr/local/searx/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/static {
  134. alias /usr/local/searx/searx/static;
  135. }
  136. location /searx {
  137. proxy_pass http://127.0.0.1:8888;
  138. proxy_set_header Host $host;
  139. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  140. proxy_set_header X-Scheme $scheme;
  141. proxy_set_header X-Script-Name /searx;
  142. proxy_buffering off;
  143. }
  144. Enable ``base_url`` in ``searx/settings.yml``
  145. .. code:: yaml
  146. base_url : http://your.domain.tld/searx/
  147. Restart service:
  148. .. code:: sh
  149. sudo -H service nginx restart
  150. sudo -H service uwsgi restart
  151. disable logs
  152. ^^^^^^^^^^^^
  153. for better privacy you can disable nginx logs about searx.
  154. how to proceed: below ``uwsgi_pass`` in ``/etc/nginx/sites-available/default``
  155. add:
  156. .. code:: nginx
  157. access_log /dev/null;
  158. error_log /dev/null;
  159. Restart service:
  160. .. code:: sh
  161. sudo -H service nginx restart
  162. with apache
  163. -----------
  164. Add wsgi mod:
  165. .. code:: sh
  166. sudo -H apt-get install libapache2-mod-uwsgi
  167. sudo -H a2enmod uwsgi
  168. Add this configuration in the file ``/etc/apache2/apache2.conf``:
  169. .. code:: apache
  170. <Location />
  171. Options FollowSymLinks Indexes
  172. SetHandler uwsgi-handler
  173. uWSGISocket /run/uwsgi/app/searx/socket
  174. </Location>
  175. Note that if your instance of searx is not at the root, you should change
  176. ``<Location />`` by the location of your instance, like ``<Location /searx>``.
  177. Restart Apache:
  178. .. code:: sh
  179. sudo -H /etc/init.d/apache2 restart
  180. disable logs
  181. ~~~~~~~~~~~~
  182. For better privacy you can disable Apache logs.
  183. .. warning::
  184. You can only disable logs for the whole (virtual) server not for a specific
  185. path.
  186. Go back to ``/etc/apache2/apache2.conf`` and above ``<Location />`` add:
  187. .. code:: apache
  188. CustomLog /dev/null combined
  189. Restart Apache:
  190. .. code:: sh
  191. sudo -H /etc/init.d/apache2 restart
  192. How to update
  193. =============
  194. .. code:: sh
  195. cd /usr/local/searx
  196. sudo -H -u searx -i
  197. .. code:: sh
  198. (searx)$ . ./searx-ve/bin/activate
  199. (searx)$ git stash
  200. (searx)$ git pull origin master
  201. (searx)$ git stash apply
  202. (searx)$ ./manage.sh update_packages
  203. .. code:: sh
  204. sudo -H service uwsgi restart
  205. Docker
  206. ======
  207. Make sure you have installed Docker. For instance, you can deploy searx like this:
  208. .. code:: sh
  209. docker pull wonderfall/searx
  210. docker run -d --name searx -p $PORT:8888 wonderfall/searx
  211. Go to ``http://localhost:$PORT``.
  212. See https://hub.docker.com/r/wonderfall/searx/ for more informations. It's also
  213. possible to build searx from the embedded Dockerfile.
  214. .. code:: sh
  215. git clone https://github.com/asciimoo/searx.git
  216. cd searx
  217. docker build -t whatever/searx .
  218. References
  219. ==========
  220. * https://about.okhin.fr/posts/Searx/ with some additions
  221. * How to: `Setup searx in a couple of hours with a free SSL certificate
  222. <https://www.reddit.com/r/privacytoolsIO/comments/366kvn/how_to_setup_your_own_privacy_respecting_search/>`__