installation.txt 6.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318
  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. }
  113. location @searx {
  114. uwsgi_param SCRIPT_NAME /searx;
  115. include uwsgi_params;
  116. uwsgi_modifier1 30;
  117. uwsgi_pass unix:/run/uwsgi/app/searx/socket;
  118. }
  119. OR
  120. using reverse proxy
  121. (Please, note that reverse proxy advised to be used in case of single-user or low-traffic instances.)
  122. .. code:: nginx
  123. location /searx {
  124. proxy_pass http://127.0.0.1:8888;
  125. proxy_set_header Host $host;
  126. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  127. proxy_set_header X-Scheme $scheme;
  128. proxy_set_header X-Script-Name /searx;
  129. proxy_buffering off;
  130. }
  131. Enable base\_url in searx/settings.yml
  132. ::
  133. base_url : http://your.domain.tld/searx/
  134. Restart service:
  135. .. code:: sh
  136. sudo service nginx restart
  137. sudo service uwsgi restart
  138. disable logs
  139. ~~~~~~~~~~~~
  140. for better privacy you can disable nginx logs about searx.
  141. how to proceed: below ``uwsgi_pass`` in
  142. /etc/nginx/sites-available/default add
  143. ::
  144. access_log /dev/null;
  145. error_log /dev/null;
  146. Restart service:
  147. .. code:: sh
  148. sudo service nginx restart
  149. with apache
  150. ^^^^^^^^^^^
  151. Add wsgi mod:
  152. .. code:: sh
  153. sudo apt-get install libapache2-mod-uwsgi
  154. sudo a2enmod uwsgi
  155. Add this configuration in the file /etc/apache2/apache2.conf:
  156. .. code:: apache
  157. <Location />
  158. Options FollowSymLinks Indexes
  159. SetHandler uwsgi-handler
  160. uWSGISocket /run/uwsgi/app/searx/socket
  161. </Location>
  162. Note that if your instance of searx is not at the root, you should
  163. change ``<Location />`` by the location of your instance, like
  164. ``<Location /searx>``.
  165. Restart Apache:
  166. .. code:: sh
  167. sudo /etc/init.d/apache2 restart
  168. disable logs
  169. """"""""""""
  170. For better privacy you can disable Apache logs.
  171. WARNING: not tested
  172. WARNING: you can only disable logs for the whole (virtual) server not
  173. for a specific path.
  174. Go back to /etc/apache2/apache2.conf and above ``<Location />`` add:
  175. .. code:: apache
  176. CustomLog /dev/null combined
  177. Restart Apache:
  178. .. code:: sh
  179. sudo /etc/init.d/apache2 restart
  180. How to update
  181. -------------
  182. .. code:: sh
  183. cd /usr/local/searx
  184. sudo -u searx -i
  185. . ./searx-ve/bin/activate
  186. git stash
  187. git pull origin master
  188. git stash apply
  189. ./manage.sh update_packages
  190. sudo service uwsgi restart
  191. Docker
  192. ------
  193. Make sure you have installed Docker. For instance, you can deploy searx like this:
  194. .. code:: sh
  195. docker pull wonderfall/searx
  196. docker run -d --name searx -p $PORT:8888 wonderfall/searx
  197. Go to http://localhost:$PORT.
  198. See https://hub.docker.com/r/wonderfall/searx/ for more informations.
  199. It's also possible to build searx from the embedded Dockerfile.
  200. .. code:: sh
  201. git clone https://github.com/asciimoo/searx.git
  202. cd searx
  203. docker build -t whatever/searx .