installation.rst 5.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  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. Basic installation
  8. ------------------
  9. For Ubuntu, be sure to have enable universe repository.
  10. Install packages :
  11. .. code:: sh
  12. sudo apt-get install git build-essential libxslt-dev python-dev python-virtualenv python-pybabel zlib1g-dev libffi-dev libssl-dev
  13. Install searx :
  14. .. code:: sh
  15. cd /usr/local
  16. sudo git clone https://github.com/asciimoo/searx.git
  17. sudo useradd searx -d /usr/local/searx
  18. sudo chown searx:searx -R /usr/local/searx
  19. Install dependencies in a virtualenv :
  20. .. code:: sh
  21. sudo -u searx -i
  22. cd /usr/local/searx
  23. virtualenv searx-ve
  24. . ./searx-ve/bin/activate
  25. pip install -r requirements.txt
  26. python setup.py install
  27. Configuration
  28. -------------
  29. .. code:: sh
  30. sed -i -e "s/ultrasecretkey/`openssl rand -hex 16`/g" searx/settings.yml
  31. Edit searx/settings.yml if necessary.
  32. Check
  33. -----
  34. Start searx :
  35. .. code:: sh
  36. python searx/webapp.py
  37. Go to http://localhost:8888
  38. If everything works fine, disable the debug option in settings.yml :
  39. .. code:: sh
  40. sed -i -e "s/debug : True/debug : False/g" searx/settings.yml
  41. At this point searx is not demonized ; uwsgi allows this.
  42. You can exit the virtualenv and the searx user bash (enter exit command
  43. twice).
  44. uwsgi
  45. -----
  46. Install packages :
  47. .. code:: sh
  48. sudo apt-get install uwsgi uwsgi-plugin-python
  49. Create the configuration file /etc/uwsgi/apps-available/searx.ini with
  50. this content :
  51. ::
  52. [uwsgi]
  53. # Who will run the code
  54. uid = searx
  55. gid = searx
  56. # disable logging for privacy
  57. disable-logging = true
  58. # Number of workers (usually CPU count)
  59. workers = 4
  60. # The right granted on the created socket
  61. chmod-socket = 666
  62. # Plugin to use and interpretor config
  63. single-interpreter = true
  64. master = true
  65. plugin = python
  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. Restart service :
  100. .. code:: sh
  101. sudo service nginx restart
  102. sudo service uwsgi restart
  103. from subdirectory URL (/searx)
  104. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  105. Add this configuration in the server config file
  106. /etc/nginx/sites-available/default :
  107. .. code:: nginx
  108. location = /searx { rewrite ^ /searx/; }
  109. location /searx {
  110. try_files $uri @searx;
  111. }
  112. location @searx {
  113. uwsgi_param SCRIPT_NAME /searx;
  114. include uwsgi_params;
  115. uwsgi_modifier1 30;
  116. uwsgi_pass unix:/run/uwsgi/app/searx/socket;
  117. }
  118. Enable base\_url in searx/settings.yml
  119. ::
  120. base_url : http://your.domain.tld/searx/
  121. Restart service :
  122. .. code:: sh
  123. sudo service nginx restart
  124. sudo service uwsgi restart
  125. disable logs
  126. ~~~~~~~~~~~~
  127. for better privacy you can disable nginx logs about searx.
  128. how to proceed : below ``uwsgi_pass`` in
  129. /etc/nginx/sites-available/default add
  130. ::
  131. access_log /dev/null;
  132. error_log /dev/null;
  133. Restart service :
  134. .. code:: sh
  135. sudo service nginx restart
  136. with apache
  137. -----------
  138. Add wsgi mod :
  139. .. code:: sh
  140. sudo apt-get install libapache2-mod-uwsgi
  141. sudo a2enmod uwsgi
  142. Add this configuration in the file /etc/apache2/apache2.conf :
  143. .. code:: apache
  144. <Location />
  145. Options FollowSymLinks Indexes
  146. SetHandler uwsgi-handler
  147. uWSGISocket /run/uwsgi/app/searx/socket
  148. </Location>
  149. Note that if your instance of searx is not at the root, you should
  150. change ``<Location />`` by the location of your instance, like
  151. ``<Location /searx>``.
  152. Restart Apache :
  153. .. code:: sh
  154. sudo /etc/init.d/apache2 restart
  155. disable logs
  156. ------------
  157. For better privacy you can disable Apache logs.
  158. WARNING : not tested
  159. WARNING : you can only disable logs for the whole (virtual) server not
  160. for a specific path.
  161. Go back to /etc/apache2/apache2.conf and above ``<Location />`` add :
  162. .. code:: apache
  163. CustomLog /dev/null combined
  164. Restart Apache :
  165. .. code:: sh
  166. sudo /etc/init.d/apache2 restart
  167. How to update
  168. -------------
  169. .. code:: sh
  170. cd /usr/local/searx
  171. sudo -u searx -i
  172. . ./searx-ve/bin/activate
  173. git stash
  174. git pull origin master
  175. git stash apply
  176. pip install --upgrade -r requirements.txt
  177. sudo service uwsgi restart