searx installation guide

Westofer

New Member


Messages: 4

I know this is very late but this thread appeaers in top google results,

I wrote a guide on how to install it here https://blog.westofer.ga/posts/installing-searx-on-freebsd/

It is my first writing and I am new to freeBSD so keep your expectations low. I am really sorry about the quality and I will try to re write it once I am done

For time travelers this site will probably be down in the future so I will copy and paste it in the next message
 

Westofer

New Member


Messages: 4

A port of searx already exists for freeBSD, so why bother? this port uses a deprecated version of python (py27)
Installing packages
pkg install py37-virtualenv python py37-pip \
py37-lxml /py37-babelfish/ git libxml2\
hs-ShellCheck \
uwsgi #optional


Fetching ports
portsnap fetch this might take a LONG time
Installing packages from ports
sudo pkg install py37-babel

creating user
Now we need to create a searx user
sudo adduser
with the following settings:
Username: searx
Full name: Searx Search Engine
Uid (Leave empty for default): *EMPTY*
Login group [searx]: *EMPTY*
Login group is searx. Invite searx into other groups? []: *EMPTY*
Login class [default]: *EMPTY*
Shell (sh csh tcsh bash rbash fish git-shell nologin) [sh]: *EMPTY*
Home directory [/home/searx]: /usr/home/searx
Home directory permissions (Leave empty for default): *EMPTY*
Use password-based authentication? [yes]: no
Lock out the account after creation? [no]: no


Install Searx and dependencies
Start an interactive shell from new created user and clone searx:
sudo -H -u searx -i
cd /usr/home/searx
git clone [URL]https://github.com/asciimoo/searx.git[/URL] ./searx-src


In the same shell create a virtualenv
python3 -m venv /usr/home/searx/searx-pyenv
echo . /usr/home/searx/searx-pyenv/bin/activate >> /usr/home/searx/.profile

To install searx's dependencies, exit the bash session open a new one (CTRL+D).
sudo -H -u searx -i
# update pip's boilerplate ..
pip install -U pip
pip install -U setuptools
pip install -U whee
l
Tip
open a second terminal for configuring the tasks and leave '(searx)$' terminal open

Configuration
In another terminal type:
sudo mkdir /usr/local/etc/searx
Then copy the settings config file to /usr/local/etc/searx
sudo -H cp /usr/home/searx/searx-src/searx/settings.yml /usr/local/etc/searx/settings.yml
*I have no idea why do we need this but it is included in the docs*

Now replace the secret key and instance name
sudo -H sed -i -e s/{ultrasecretkey}/\367ed0f4f4f300bd1457e5c87d036ab2/g /usr/local/etc/searx/settings.yml
sudo -H sed -i -e s/{instance_name}/searx@\ryzen/g /etc/searx/settings.yml

Sed didn't work for me for some reason, so change it manually! (line #3 and #15)

Check
To check searx , enable optional debugging and start the webapp. (line #2)
Code:
debug: False
#change it to
debug True
Then we can start the web app
sudo -H -u searx -i
cd /usr/local/searx/searx-src
export SEARX_SETTINGS_PATH=/usr/local/etc/searx/settings.yml
python searx/webapp.py


Testing!
if freeBSD is installed in your local machine then simply open localhost:8888 in a browser, if you are in a ssh session, then you need to bind address to your local machine.
#run in your local machine
ssh -L 8888:localhost:8888 username@server [cmd]

now you should be able to open searx in localhost:8888 in your browser!
At this point searx is not demonized, this why we should use [B]uwsgi[/B] or [B]pm2[/B]. You should also change Debug to False in setting.yml [file] /usr/local/etc/searx/settings.yml [/file]
[cmd]
debug: False
#change it to
debug True


Demonizing Searx with pm2


Official docs use uwsgi, however I believe that pm2 is way easier
Install node if you dont have it already
sudo pkg install node www/npm
Install pm2 with
sudo npm i -g pm2

start pm2 on startup with the following
pm2 startup
you will then be given a command to copy/paste (note that it doesn't work in fish shell, use sh)
Now start searx with pm2

sudo -H -u searx -i
cd /usr/home/searx/searx-src
sudo pm2 start searx/webapp.py
[cmd]

Also save pm2 settings for next startup

[cmd]sudo pm2 save


Installing nginx
This guide is getting quit long and I think dividing it would be better :)
 

Westofer

New Member


Messages: 4

Setting up Nginx For Searx in freeBSD

This blog post was written by a freeBSD noob. I just wrote how I did it, which might not be the most efficient way possible :)
Installing packages
Install nginx
Install nginx with
sudo pkg install nginx
Install certbot
sudo pkg install py37-cerbot

Configuring
configure nginx
Add nginx to /etc/rc.conf

Code:
 #/etc/rc.conf
nginx_enable="YES"
and enable it
sudo service nginx start
Create a sites-enabled directory
sudo mkdir /usr/local/etc/nginx/sites-enabled
Create a conf file for searx
sudo touch /usr/local/etc/nginx/sites-enabled/searx.conf
Then we need to edit nginx.conf this way we are going to have the search engine in a subdomoin (for example searx.westofer.ga)
This file is going to be the homepage (in my example https://westofer.ga)

Code:
#/usr/local/etc/nginx/nginx.conf
worker_processes 1;
events {
    worker_connections 1024;
}

http {
    include mime.types;
    default_type application/octet-stream;
    include /usr/local/etc/nginx/sites-enabled/*;
    sendfile on;
    keepalive_timeout 65;

    server {
        listen 80;
        server_name YOUR-DOMAIN.COM;
        #charset koi8-r;
        #access_log  logs/host.access.log  main;

    location / {
        root /usr/local/www/nginx;
        index index.html index.htm;
    }
}
Now for the /usr/local/etc/nginx/sites-enabled/searx.conf
Code:
server {
    listen 80;
    listen [::]:80;
    access_log /dev/null;
    error_log /dev/null;

    root /var/www/subdomain.example.com;
    index index.html index.htm index.nginx-debian.html;
    server_name searx.domain.com;

    location / {
        proxy_pass http://localhost:8888; #port for searx
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
    }
}
Restarting nginx server
sudo service nginx restart

SSL certificate (https)
now you should see your website running in http://searx.domain.com, which is insecure, so we should upgrade to https with a SSL certificate from certbot.
 

Westofer

New Member


Messages: 4

Nginx Certbot In Freebsd

Installation
First we need to install certbot
sudo pkg install py37-certbot
Stop nginx to install the certificates
sudo service nginx stop
now we can safley run certbot
sudo certbot certonly --standalone
type your email , domain and sub domains when prompted
you should recieve a success message saying
  • Congratulations! Your certificate and chain have been saved at: /usr/local/etc/letsencrypt/live/DOMAIN.COM/fullchain.pem Your key file has been saved at: /usr/local/etc/letsencrypt/live/DOMAIN.COM/privkey.pem Your cert will expire on 2020-10-24. To obtain a new or tweaked version of this certificate in the future, simply run certbot again. To non-interactively renew all of your certificates, run " certbot renew"
  • If you like Certbot, please consider supporting our work by:........
run the following to get auto-renewal (all in one line)
echo "0 0,12 * * * root python -c 'import random; import time; time.sleep(random.random() * 3600)' && certbot renew -q" | sudo tee -a /etc/crontab > /dev/null
Modifing nginx conf
Now go to /usr/local/etc/nginx/sites-avialable/searx.conf and change it to
Code:
server {

    listen 80;
    listen [::]:80;
    access_log /dev/null;
    error_log /dev/null;

    server_name searx.DOMAIN.COM;
    return 301 https://$server_name$request_uri;
}

server {

    listen 443 ssl;
    server_name www.searx.DOMAIN.COM;
    ssl_certificate /usr/local/etc/letsencrypt/live/DOMAIN.com/fullchain.pem;
    ssl_certificate_key /usr/local/etc/letsencrypt/live/DOMAIN.com/privkey.pem;


    location / {
        proxy_pass http://localhost:8888;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
}
}
 
Top