searxのインストール
目次
概要
searxは検索エンジンの使用による個人情報の漏洩がないように配慮された、ハッカブルなメタサーチエンジンである。 メタサーチエンジンというのは、与えられたクエリを登録されているいくつかの検索エンジンで検索し、その検索結果をまとめて表示するというもの。
公式のインストール方法を見ながらインストールした。
テスト環境
Slackware Linux x86_64 14.1
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
仮想環境にインストールする:
sudo -u searx -i cd /usr/local/searx virtualenv searx-ve . ./searx-ve/bin/activate ./manage.sh update_packages deactivate
シークレットキーの作成:
sed -i -e "s/ultrasecretkey/`openssl rand -hex 16`/g" searx/settings.yml
デバッグモードではなくする
sed -i -e "s/debug : True/debug : False/g" searx/settings.yml
searx/settings.yml
を編集して、port
でポート、bind_address
でIPアドレス、base_url
にベースURLを設定。
port : 443 bind_address : "xxx.yyy.zzz.www" # address to listen on base_url : "https://searx.example.com/" # Set custom base_url. Possible value
uwsgi
SlackBuildsから以下をインストール:
- network/uwsgi
このSlackBuildのインストールの際に、解凍したソースコードの中にapache2のモジュールのソースがあるのだが、SlackBuildではいまのところ自動でビルド・インストールされないので、手動でする必要がある。
cd /tmp/SBo/uwsgi-2.0.8/apache2 sudo apxs -i -c mod_uwsgi.c sudo apxs -i -c mod_Ruwsgi.c sudo apxs -i -c mod_proxy_uwsgi.c
searxの設定ファイルを作成:
sudo vim /etc/uwsgi.ini
そして次のように編集する:
[uwsgi] socket = /tmp/searx-socket # 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 # 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/
ソケット用パスを作成
sudo mkdir -p /run/uwsgi/app/searx sudo chown searx:searx /run/uwsgi/app/searx
とりあえずの起動スクリプトを作成した(要start-stop-daemon):
vim /etc/rc.d/rc.uwsgi
#!/bin/bash ### BEGIN INIT INFO # Provides: uwsgi # Required-Start: $local_fs $remote_fs $network $syslog # Required-Stop: $local_fs $remote_fs $network $syslog # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: starts uwsgi # Description: starts uwsgi ### END INIT INFO # configuration SSD=/sbin/start-stop-daemon NAME="uwsgi" DAEMON=/usr/bin/uwsgi PIDFILE="/var/run/uwsgi.pid" DAEMON_ARGS="-d --ini /etc/uwsgi.ini --enable-threads" # commands case $1 in start) echo "Starting "$NAME"..." $SSD --start --name $NAME --exec $DAEMON -- $DAEMON_ARGS #1> /dev/null 2>&1 ;; stop) echo "Stopping "$NAME"..." $SSD --stop --quiet --retry=QUIT/30/KILL/5 --pidfile $PIDFILE --name uwsgi RETVAL="$?" [ "$RETVAL" = 2 ] && return 2 $SSD --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON [ "$?" = 2 ] && return 2 rm -f $PIDFILE exit "$RETVAL" ;; status) status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $? ;; reload) echo "Reloading" $SSD --stop --signal 1 --quiet --pidfile $PIDFILE --name $NAME exit 0 ;; *) echo "Usage: $0 {start|stop|status|reload}" exit 1 ;; esac exit 0
起動スクリプトに実行権限を与える:
sudo chmod +x /etc/rc.d/rc.uwsgi
開始してみる:
/etc/rc.d/rc.uwsgi start
apache2の設定
/etc/httpd/httpd.conf
へ下記の一行を追加:
LoadModule uwsgi_module lib64/httpd/modules/mod_uwsgi.so
/etc/httpd/extra/httpd-vhosts.conf
へ追加:
# searx <VirtualHost *:443> DocumentRoot /usr/local/searx ServerName search.yourdomain.net:443 ErrorLog /var/log/httpd/search.yourdomain.net-error_log CustomLog /var/log/httpd/search.yourdomain.net-access_log common <Location /> Options FollowSymLinks Indexes SetHandler uwsgi-handler uWSGISocket /tmp/searx-socket </Location> <Directory /usr/local/searx> Options +FollowSymLinks AllowOverride All Require all granted </Directory> #SSL Engine Switch: #Enable/Disable SSL for this virtual host. SSLEngine on # Server Private Key: # If the key is not combined with the certificate, use this # directive to point at the key file. Keep in mind that if # you've both a RSA and a DSA private key you can configure # both in parallel (to also allow the use of DSA ciphers, etc.) SSLCertificateFile "/etc/letsencrypt/live/yourdomain.net/cert.pem" SSLCertificateKeyFile "/etc/letsencrypt/live/yourdomain.net/privkey.pem" SSLCertificateChainFile "/etc/letsencrypt/live/yourdomain.net/chain.pem" </VirtualHost>
ここではHTTPSを使うように設定した。
Firefox/Icecatの検索バーで使う
Icecatを閉じて、searx-meプラグインをダウンロードして、アドレスの部分を書き換えて、次のようにsearchpluginsディレクトリへコピーする:
cp Downloads/searx-yourdomain-20150226.xml .mozilla/icecat/xxxxxxxx.default-0000000000000/searchplugins/
そしてFirefox/Icecatを起動すると、検索エンジンの選択肢に現れる。
トラブルシューティング
再起動したら500エラーが出る
再起動したら検索がうまく表示されず、さらに設定の保存で500エラーが出るようになった。
searx/settings.yml
を編集して
default_theme : pix-art # ui theme
を
default_theme : default #pix-art # ui theme
にしたら直った。