installation.rst 6.3 KB

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