searx是一个用python开发的尊重隐私的聚合搜索引擎,搜索结果还是从各大搜索引擎抓取的,但不会记录你的cookie等信息,可以避免搜索引擎的追踪/AD精准投放等。。
这里水两种/两个系统的安装方法。。。
第一种使用Docker快速体验,开始前你需要准备一个域名解析到你的VPS。然后安装docker:
yum -y install curl 或者 apt -y install curl curl -sSL https://get.docker.com/ | sh systemctl start docker systemctl enable docker
安装docker-compose:
curl -L "https://github.com/docker/compose/releases/download/1.24.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose chmod +x /usr/local/bin/docker-compose
新建一个docker-compose的配置文件:
mkdir -p /opt/searx-docker && cd /opt/searx-docker && nano /opt/searx-docker/docker-compose.yml
写入如下配置:
version: "3" services: searx: image: wonderfall/searx restart: always environment: BASE_URL: "https://searx.koko.cat" IMAGE_PROXY: "True" caddy: image: abiosoft/caddy restart: always volumes: - ./Caddyfile:/etc/Caddyfile:ro - caddycerts:/root/.caddy ports: - 80:80 - 443:443 environment: ACME_AGREE: "true" DOMAIN: "searx.koko.cat" EMAIL: "[email protected]" volumes: caddycerts:
上面这个配置文件有3个要改动的地方:BASE_URL/DOMAIN/EMAIL
接着再新建一个Caddy的配置文件:
nano Caddyfile
什么都不用改动,直接写入如下配置:
{$DOMAIN} { log stdout gzip tls {$EMAIL} proxy / searx:8888 { header_upstream Host {host} header_upstream X-Real-IP {remote} header_upstream X-Forwarded-For {remote} header_upstream X-Forwarded-Port {server_port} header_upstream X-Forwarded-Proto {scheme} } }
如果是使用的CentOS7,那么需要放行80/443:
firewall-cmd --permanent --add-service=http firewall-cmd --permanent --add-service=https firewall-cmd --reload
启动:
docker-compose up -d
下面是手动安装的方法,手动的话肯定复杂一点,但也可以更详细的“定制”一下。。
CentOS7安装所需的依赖包:
yum -y groupinstall "Development Tools" yum -y install git python-babel python-devel python-virtualenv zlib-devel libffi-devel libxslt-devel openssl-devel uwsgi uwsgi-plugin-python supervisor
Debian9安装所需的依赖包:
apt -y install git build-essential python-babel python-dev python-virtualenv zlib1g-dev libffi-dev libxslt-dev libssl-dev uwsgi uwsgi-plugin-python supervisor
CentOS7安装Golang:
wget https://dl.google.com/go/go1.12.5.linux-amd64.tar.gz tar -xzvf go1.12.5.linux-amd64.tar.gz -C /usr/bin echo "export PATH=$PATH:/usr/bin/go/bin" >> ~/.bash_profile source ~/.bash_profile
Debian9安装Golang:
wget https://dl.google.com/go/go1.12.5.linux-amd64.tar.gz tar -xzvf go1.12.5.linux-amd64.tar.gz -C /usr/bin echo "export PATH=$PATH:/usr/bin/go/bin" >> ~/.profile source ~/.profile
构建morty,这是一个额外的小工具,作用是可以去掉网页内的一些恶意元素,不是一定要部署的,但如果你选择部署那么此时就得再准备一个二级域名解析到你的VPS,然后执行下面的命令:
cd /opt && mkdir morty && export GOPATH=$PWD/morty go get -u github.com/asciimoo/morty cp /opt/morty/bin/morty /usr/bin
拉取searx的项目文件:
cd /opt git clone https://github.com/asciimoo/searx.git
执行两次如下命令,将生成出来的随机数复制保存:
openssl rand -hex 16
编辑searx的配置文件:
nano /opt/searx/searx/settings.yml
要改动的地方如下:
search: language : "zh-CN" server: port : 8888 bind_address : "127.0.0.1" secret_key : "a1a3a826a9f80fc077ebf6d27f4dc4ff" ui: default_locale : "zh" result_proxy: url : https://morty.koko.cat key : f02574f55b75a74ddbcf31f1fcc545df
注:其中的secret_key/key使用你之前生成的随机数替换
启用py的虚拟环境/安装项目所需依赖:
cd /opt/searx virtualenv searx-prod source searx-prod/bin/activate pip install --upgrade pip pip install --upgrade setuptools pip install --upgrade gunicorn ./manage.sh update_packages
CentOS7新建supervisor的配置文件:
nano /etc/supervisord.d/searx.ini
Debian9新建supervisor的配置文件:
nano /etc/supervisor/conf.d/searx.conf
写入如下配置:
[supervisord] nodaemon=false [program:searx] priority=1 directory=/opt/searx command=/opt/searx/searx-prod/bin/gunicorn -b 127.0.0.1:8888 searx.webapp:app autorestart=true [program:morty] priority=1 directory=/usr/bin command=/usr/bin/morty -listen 127.0.0.1:3000 -key f02574f55b75a74ddbcf31f1fcc545df autorestart=true
注:morty启动参数后面的key要和之前在settings.yml内配置的保持一致。
CentOS7重启supervisor使其生效:
systemctl restart supervisord systemctl enable supervisord
Debian9重启supervisor使其生效:
systemctl restart supervisor systemctl enable supervisor
安装并新建Caddy的配置文件:
curl https://getcaddy.com | bash -s personal mkdir -p /etc/caddy && mkdir -p /etc/ssl/caddy nano /etc/caddy/Caddyfile
caddy的配置如下:
searx.koko.cat { log stdout gzip tls [email protected] proxy / 127.0.0.1:8888 { header_upstream Host {host} header_upstream X-Real-IP {remote} header_upstream X-Forwarded-For {remote} header_upstream X-Forwarded-Port {server_port} header_upstream X-Forwarded-Proto {scheme} } } morty.koko.cat { log stdout gzip tls [email protected] proxy / 127.0.0.1:3000 { header_upstream Host {host} header_upstream X-Real-IP {remote} header_upstream X-Forwarded-For {remote} header_upstream X-Forwarded-Port {server_port} header_upstream X-Forwarded-Proto {scheme} } }
新建systemd服务文件:
nano /etc/systemd/system/caddy.service
写入如下配置:
[Unit] Description=Caddy HTTP/2 web server Documentation=https://caddyserver.com/docs After=network-online.target Wants=network-online.target systemd-networkd-wait-online.service [Service] Restart=on-abnormal User=root Group=root Environment=CADDYPATH=/etc/ssl/caddy ExecStart=/usr/local/bin/caddy -log stdout -agree=true -conf=/etc/caddy/Caddyfile ExecReload=/bin/kill -USR1 $MAINPID KillMode=mixed KillSignal=SIGQUIT TimeoutStopSec=5s [Install] WantedBy=multi-user.target
启动Caddy:
systemctl start caddy systemctl enable caddy
有个小bug要修一下。。也谈不上是修。。这个最新版本如果用默认的主题+中文的话,preferences(首选项)的页面打不开,会报错500。。
如果你碰到了上述问题,我暂时的解决办法是,编辑如下文件:
nano /opt/searx/searx/templates/oscar/preferences.html
把如图的78行给删掉:
重启searx:
supervisorctl restart searx
怎么说呢,用还是阔以用的,就是得设置一下,首先我建议你打开首选项,把Google的搜索给关闭了,然后启用duckduckgo/yahoo:
因为Google搜索的时候可能会弹一个人机验证的验证码,这个程序无法处理验证码,导致程序会报错。当然如果你VPS的IP比较干净的话,应该不会频繁出验证码就是。。
随便试试?搜个稍微敏感点的话题:
最新评论
5211314
能不能教我 一点不会