installation.rst 6.1KB

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