Searx
mercredi 23 octobre 2013 à 10:58Welcome to searx
You might have noticed some change on my seeks node since it's not a seeks node anymore, but instead it's a searx node.
Searx is a project started by asciimoo after Taziden gave a talk at Camp zer0 about going forward with seeks and opening it up to a wider base of developper.
The idea is that seeks ‑ currently written in hardcore C++ ‑ is a prototype and an exploratory project about search and decentralization of search, and that we can now build almost from scratch a search engine which will implement the concept behind seeks but in a more developper friendly way, for instance in python.
We already had a lot of discussion with people hanging on #seeks@irc.freenode.net about this and, technically, there's two tool to develop. An easily extensible metasearch engine which will feed a DHT of result shared with different nodes.
And then asciimoo wrote searx, a meta search engine, easily extensible. Now, we "just" have to connect it to a DHT. But I'll save that for later.
So, how did I installed it? I've fought a little bit with uwsgi and nginx, but now it works. Here's how:
Setup
Getting the code, the dependencies and everything else
Create a searx user for it's a good practice (don't run things as root) and do some git cloning and virtualise you're environment. Oh, before I forgot, I'm running a debian stable and I try to keep the distribution clean (so no pip install outside of virtualenv)
cd /usr/local
git clone https://github.com/asciimoo/searx.git
chown searx:searx -R /usr/local/searx
cd /usr/local/searx
virtualenv searx-ve
. searx-ve/bin/activate/
Now, you have a running virtual environnement in ''/usr/local/searx/searx-ve'' and the code in the parent directory. You need to install some dependencies, so launch that command and go get a cup of coffee.
pip install -r requirements.txt
Now, the code is alive. You can test it by running the flask instance:
python searx/webapp.py
And you can proxy requests to ''http://localhost:8888'' from your favorite webserver. It works.
Uwsgi
Since it's not daemonized, and you've got only one worker, I wanted to have something more maintainable. So I needed something like uwsgi (or gunicorn, or whatever) to run the apps right from nginx.
Since debian splitted uwsgi config in a lot of modules, don't forget to install python module (I was stuck with that a lot). So, let's install uwsgi and required dependencies.
apt-get install uwsgi uwsgi-plugin-python
Next step is to create an app. In debian, uwsgi has the same apps-{available,enabled} file structure than on nginx or apache. Here' my config file for searx:
vim /etc/uwsgi/apps-available/searx.ini
[uwsgi]
# Who will run the code
uid = searx
gid = searx
# Number of workers
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
# Application base folder
base = /usr/local/searx
# 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/
# The variable holding flask application
callable = app
Once that's done, symlink this file in apps-enabled and start uwsgi.
cd /etc/uwsgi/apps-enabled
ln -s ../apps-available/searx.ini
/etc/init.d/uwsgi start
By default, the socket used by uwsgi will be in ''/run/uwsgi/ap/searx/socket''. This is where nginx will chat with uwsgi.
Nginx
Hard part is done, if you already have nginx installed, just use yet another vhost.
vim /etc/nginx/sites-available/searx
server {
listen 80;
server_name searx.example.com;
root /usr/local/searx
location / {
include uwsgi_params;
uwsgi_pass unix:/run/uwsgi/app/searx/socket;
}
}
Then activate the newly created sites and restart nginx.
ln -s /etc/nginx/sites-{enabled,available}/searx
/etc/init.d/nginx restart
And go visit searx.example.com or whatever your FQDN is) on port 80, it would works.
I suggest you to install some SSL? but it's beyond the scope of this tutorial.
Have fun.