installation.txt 5.7KB

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