installation.rst 5.6KB

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