Skip to content

Example step by step installation using nginx and SQLite

Poorchop edited this page Jun 1, 2016 · 2 revisions

This is a detailed guide to get a working selfoss installation using nginx and SQLite with Fedora 23 as the host OS. These steps can be used as guidance for installation in other distros by using the equivalent packages and the distro's package manager.

Install the necessary packages:

dnf install nginx sqlite cronie wget curl unzip php php-fpm php-gd php-mbstring php-pdo php-tidy php-xml

Start nginx and enable the systemd service:

systemctl start nginx
systemctl enable nginx

Configure PHP:

vim /etc/php.ini

Find the line that starts with cgi.fix_pathinfo and change it to the following:

cgi.fix_pathinfo=0

Now save the file and exit vim.

Configure PHP-FPM:

vim /etc/php-fpm.d/www.conf

Find the user and group lines, which are set to apache by default, and change them to the following:

user = nginx
group = nginx

Also ensure that you are listening over TCP/IP since listening over sockets might give you a 502 bad gateway error later on:

listen = 127.0.0.1:9000

Save and exit vim, and then enable and restart PHP-FPM:

systemctl restart php-fpm
systemctl enable php-fpm

Download the latest stable selfoss package onto your sever.

At the time of writing this, 2.15 is the latest stable release.

mkdir -p /tmp/selfoss
cd /tmp/selfoss
wget https://github.com/SSilence/selfoss/releases/download/2.15/selfoss-2.15.zip
unzip selfoss-2.15.zip
rm selfoss-2.15.zip
cd ..
mv selfoss/ /var/www
cd /var/www/selfoss

Make the appropriate directories writable.

Selfoss needs write permissions to the following directories in order to function properly:

chmod 775 data/cache data/favicons data/logs data/thumbnails data/sqlite public/

The web server user (nginx) should also own the selfoss directory:

chown -R nginx:nginx /var/www/selfoss/

Create a configuration file for nginx:

vim /etc/nginx/conf.d/selfoss.conf

Type the following into the file, changing server_name to the appropriate address for your server. After this step, save and exit vim.

server {
    listen 80;
    listen 443 ssl;
    server_name rss.yourdomain.com;
    root /var/www/selfoss/;
    access_log /var/log/nginx/rss.access.log;
    error_log /var/log/nginx/rss.error.log;

    location ~* \ (gif|jpg|png) {
        expires 30d;
    }

    location ~ ^/favicons/.*$ {
        try_files $uri /data/$uri;
    }

    location ~ ^/thumbnails/.*$ {
        try_files $uri /data/$uri;
    }

    location ~* ^/(data\/logs|data\/sqlite|config\.ini|\.ht) {
        deny all;
    }

    location / {
        index index.php index.html index.htm;
        try_files $uri /public/$uri /index.php$is_args$args;
    }

    location ~ \.php$ {
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }
}

Note: If you plan to enable password protection for selfoss, you should only be using SSL. There are plenty of guides available online for configuring nginx to redirect all http requests to https. Keep in mind that you can always use a self-signed certificate.

Restart nginx and start using selfoss!!

systemctl restart nginx

Now connect to rss.yourdomain.com and start adding some RSS feeds to selfoss.

Set up auto-updating of your RSS feeds

As a regular user (non-root):

crontab -e

Now add the following rule for automatically fetching updates every 30 minutes:

*/30 * * * * /usr/bin/curl -Ls 'http://rss.yourdomain.com/update' >/dev/null

If you're using a self-signed certificate, you can also use the -k option with curl.

After saving your cron job:

cp /var/www/selfoss/defaults.ini /var/www/selfoss/config.ini
vim /var/www/selfoss/config.ini

Set the following option:

allow_public_update_access=1

If quite some time elapses and you notice that your feeds aren't automatically updating, then perhaps you need to start the crond service:

systemctl start crond

Some final notes:

  • If you are here, chances are that you already read through the documentation on the selfoss website, but if not, then go ahead and do so. There are plenty of additional instructions on the website that will help you tailor selfoss to your liking.
  • If you run into any issues during installation, be sure to check rss.error.log. This error log is extremely valuable for troubleshooting as it will tell you exactly what your configuration issues are.
  • If you are using SELinux, make sure that you set the appropriate policies where needed. Don't forget to set write permissions on the appropriate data/* and public/ directories.