Searx互聯(lián)網(wǎng)元搜索引擎
Searx是一個免費的互聯(lián)網(wǎng)元搜索引擎,匯集了70多種搜索服務的結果。 用戶既不被跟蹤也不被分析。 此外,searx可以在Tor上實現(xiàn)在線匿名搜索。
基本安裝
下面是基于 Debian/Ubuntu 和 virtualenv 的安裝指南,如果是 Ubuntu 請確認使用的是 universe 倉庫。
安裝依賴包:
sudo apt-get install git build-essential libxslt-dev python-dev python-virtualenv python-babel zlib1g-dev libffi-dev libssl-dev
安裝 searx:
cd /usr/local sudo git clone https://github.com/asciimoo/searx.git sudo useradd searx -d /usr/local/searx sudo chown searx:searx -R /usr/local/searx
在 virtualenv 中安裝依賴:
sudo -u searx -i cd /usr/local/searx virtualenv searx-ve . ./searx-ve/bin/activate ./manage.sh update_packages
配置
sed -i -e "s/ultrasecretkey/`openssl rand -hex 16`/g" searx/settings.yml
根據(jù)需要修改 searx/settings.yml
檢查
啟動 searx:
python searx/webapp.py
瀏覽器訪問 http://localhost:8888
如果一切工作正常,可以在 settings.yml 中禁用調(diào)試選項:
sed -i -e "s/debug : True/debug : False/g" searx/settings.yml
配合 uwsgi 使用
安裝依賴包
sudo apt-get install uwsgi uwsgi-plugin-python
創(chuàng)建配置文件 /etc/uwsgi/apps-available/searx.ini,內(nèi)容如下:
[uwsgi] # Who will run the code uid = searx gid = searx # disable logging for privacy disable-logging = true # Number of workers (usually CPU count) workers = 4 # The right granted on the created socket chmod-socket = 666 # Plugin to use and interpretor config single-interpreter = true master = true plugin = python lazy-apps = true enable-threads = true # Module to import module = searx.webapp # Virtualenv and python path virtualenv = /usr/local/searx/searx-ve/ pythonpath = /usr/local/searx/ chdir = /usr/local/searx/searx/
激活 uwsgi 應用并重啟
cd /etc/uwsgi/apps-enabled ln -s ../apps-available/searx.ini /etc/init.d/uwsgi restart
Web 服務器
nginx
使用如下命令安裝 Nginx
sudo apt-get install nginx
配置到 / 根路徑
創(chuàng)建配置文件 /etc/nginx/sites-available/searx 內(nèi)容如下:
server {
listen 80;
server_name searx.example.com;
root /usr/local/searx;
location / {
include uwsgi_params;
uwsgi_pass unix:/run/uwsgi/app/searx/socket;
}
}
重啟服務:
sudo service nginx restart sudo service uwsgi restart
配置到指定路徑 (/searx)
添加配置文件 /etc/nginx/sites-enabled/default 內(nèi)容如下:
location = /searx { rewrite ^ /searx/; }
location /searx {
try_files $uri @searx;
}
location @searx {
uwsgi_param SCRIPT_NAME /searx;
include uwsgi_params;
uwsgi_modifier1 30;
uwsgi_pass unix:/run/uwsgi/app/searx/socket;
}
或者使用反向代理(適合單用戶使用或者低訪問量的實例)
location /searx {
proxy_pass http://127.0.0.1:8888;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Scheme $scheme;
proxy_set_header X-Script-Name /searx;
proxy_buffering off;
}
編輯 searx/settings.xml 中的 base_url
base_url : http://your.domain.tld/searx/
重啟服務:
sudo service nginx restart sudo service uwsgi restart
為了更好的保護隱私,可以禁用日志,在 /etc/nginx/sites-available/default 的 uwsgi_pass 下面增加如下內(nèi)容:
access_log /dev/null; error_log /dev/null;
重啟服務
sudo service nginx restart
apache
增加 wsgi mod:
sudo apt-get install libapache2-mod-uwsgi sudo a2enmod uwsgi
增加配置內(nèi)容到 /etc/apache2/apache2.conf:
<Location />
Options FollowSymLinks Indexes
SetHandler uwsgi-handler
uWSGISocket /run/uwsgi/app/searx/socket
</Location>
N注意,如果你的 searx 實例不是部署在根路徑,需要修改 <Location /> 配置信息,如 <Location /searx>.
重啟 Apache:
sudo /etc/init.d/apache2 restart
禁用日志
回到配置文件 /etc/apache2/apache2.conf 在 <Location /> 指令上方增加:
CustomLog /dev/null combined
重啟 Apache:
sudo /etc/init.d/apache2 restart
如何更新
cd /usr/local/searx sudo -u searx -i . ./searx-ve/bin/activate git stash git pull origin master git stash apply ./manage.sh update_packages sudo service uwsgi restart
Docker
確認你已裝有 Docker ,然后使用如下命令來部署 searx:
docker pull wonderfall/searx docker run -d --name searx -p $PORT:8888 wonderfall/searx
打開瀏覽器訪問 http://localhost:$PORT.
更多的幫助請看 https://hub.docker.com/r/wonderfall/searx/
你也可以通過 Dockerfile 來構建 searx
git clone https://github.com/asciimoo/searx.git cd searx docker build -t whatever/searx .
參考資料
- https://about.okhin.fr/posts/Searx/ with some additions
- How to: Setup searx in a couple of hours with a free SSL certificate
