VPS/Servers management guides

How to Install selfoss RSS Reader on AlmaLinux 9 or Rocky Linux 9

Set up the self-hosted selfoss RSS reader on AlmaLinux 9 or Rocky Linux 9 with Apache, PHP-FPM, SELinux rules, password login and scheduled feed updates.

selfoss is a self-hosted, web-based RSS reader and feed aggregator written in PHP. This guide installs the current stable release, selfoss 2.19, on AlmaLinux 9 or Rocky Linux 9 with Apache and PHP, protects it with a login, and schedules automatic feed updates. By the end you will have your own reader at http://rss.example.com/ that you can use from a desktop or mobile browser.

CentOS 7 reached end of life on 30 June 2024; AlmaLinux 9, Rocky Linux 9 and CentOS Stream 9 replace it. The RHEL 9 family is used here because selfoss documents Apache as its primary web server and release 2.19 requires PHP 7.2 or newer, both of which these distributions provide from their standard repositories. The steps are the same on all three.

Requirements

  • A server running AlmaLinux 9, Rocky Linux 9 or CentOS Stream 9, and a user with sudo rights.
  • A DNS record (here rss.example.com) pointing to the server.
  • Apache with mod_rewrite, mod_headers and mod_authz_core, and permission for .htaccess files to set rewrite rules. The stock httpd package loads all three modules.
  • PHP with the gd extension; some feed sources also use curl and mbstring.
  • A database: SQLite (the default, no setup needed), MySQL/MariaDB or PostgreSQL.

Step 1: Install Apache and PHP

Install the web server, PHP and the extensions selfoss uses:

sudo dnf install httpd php php-cli php-gd php-mbstring php-xml php-pdo php-mysqlnd unzip

On the RHEL 9 family, Apache hands PHP requests to PHP-FPM, so start and enable both services:

sudo systemctl enable --now httpd php-fpm

Check the PHP version:

php -v

Step 2: Download selfoss

Download the release archive from the project's GitHub releases and unpack it. The archive contains a single selfoss directory:

cd /tmp
curl -LO https://github.com/fossar/selfoss/releases/download/2.19/selfoss-2.19.zip
sudo unzip selfoss-2.19.zip -d /var/www/

The application is now in /var/www/selfoss, including the hidden .htaccess file it depends on.

Step 3: Set permissions and SELinux contexts

PHP must be able to write to five sub-directories of data: cache, favicons, logs, thumbnails and sqlite. Give the whole data directory to the apache user and leave the rest owned by root:

sudo chown -R apache:apache /var/www/selfoss/data

SELinux is enforcing by default and blocks two things selfoss needs: writing to data and making outbound connections to fetch feeds. Allow both:

sudo semanage fcontext -a -t httpd_sys_rw_content_t "/var/www/selfoss/data(/.*)?"
sudo restorecon -R /var/www/selfoss
sudo setsebool -P httpd_can_network_connect 1

If semanage is missing, install it with sudo dnf install policycoreutils-python-utils.

Step 4: Create the Apache virtual host

Create a configuration file for the site:

sudo nano /etc/httpd/conf.d/selfoss.conf

Add the following. AllowOverride All is what lets the bundled .htaccess file apply its rewrite rules:

<VirtualHost *:80>
    ServerName rss.example.com
    DocumentRoot /var/www/selfoss

    <Directory /var/www/selfoss>
        AllowOverride All
        Require all granted
    </Directory>

    ErrorLog /var/log/httpd/selfoss_error.log
    CustomLog /var/log/httpd/selfoss_access.log combined
</VirtualHost>

Test the configuration, reload Apache and open the firewall:

sudo apachectl configtest
sudo systemctl reload httpd
sudo firewall-cmd --permanent --add-service=http --add-service=https
sudo firewall-cmd --reload

Open http://rss.example.com/. selfoss creates its SQLite database on the first request and shows an empty reader. At this point anyone can open it and add feeds, so set a login next.

Step 5: Protect selfoss with a login

selfoss stores a password hash, not the password. Open http://rss.example.com/password, type the password you want and copy the hash it generates. Then create the configuration file:

sudo nano /var/www/selfoss/config.ini

Only the options you want to change need to be in this file. For a login, two lines are enough; paste your own hash:

username=deploy
password="$2y$10$replace-this-with-the-hash-you-generated"

The release notes for 2.19 list a known regression: values that contain special characters must be quoted, which is why the hash is in double quotes. Reload the page and selfoss asks you to sign in. The bundled .htaccess denies web access to .ini files, so the configuration cannot be downloaded.

The archive also includes config-example.ini with every option and its default value; the configuration options page explains them.

Step 6 (optional): Use MariaDB instead of SQLite

SQLite is fine for one person with a few hundred feeds. If you prefer MariaDB, install it and create a database and user:

sudo dnf install mariadb-server
sudo systemctl enable --now mariadb
sudo mysql
CREATE DATABASE selfoss CHARACTER SET utf8mb4;
CREATE USER 'selfoss'@'localhost' IDENTIFIED BY 'change-this-password';
GRANT ALL PRIVILEGES ON selfoss.* TO 'selfoss'@'localhost';
EXIT;

Add the connection settings to /var/www/selfoss/config.ini:

db_type=mysql
db_host=localhost
db_database=selfoss
db_username=selfoss
db_password="change-this-password"

selfoss creates its tables automatically on the next request. The database user must be allowed to create triggers, which ALL PRIVILEGES covers. Feeds added while using SQLite are not carried over, so choose the database before you start subscribing.

Step 7: Update feeds automatically

selfoss only fetches new items when its update job runs. The project provides cliupdate.php for this. Run it once by hand as the apache user to confirm it works:

sudo -u apache php /var/www/selfoss/cliupdate.php

Then schedule it. Create a cron file:

sudo nano /etc/cron.d/selfoss

This entry updates all feeds every 30 minutes:

*/30 * * * * apache /usr/bin/php /var/www/selfoss/cliupdate.php

Running the job as apache keeps the cache, thumbnails and SQLite file writable by the web server.

Add feeds and import subscriptions

Sign in, open the settings (the cog icon or /manage/sources) and add a source: choose the "RSS Feed" type and paste the feed URL. To move from another reader, export its subscriptions as an OPML file and upload it at http://rss.example.com/opml.

If feeds stay empty after an update, look in /var/www/selfoss/data/logs/default.log. For more detail, add logger_level=DEBUG to config.ini temporarily; the log grows quickly at that level.

Updating selfoss

To move to a newer release, back up the database and the data directory, delete every other file and directory except data and config.ini, and copy in the new files (including .htaccess) without overwriting data. Database changes are applied automatically. Then clear your browser cache.

The project's change log states that the next release, 2.20, requires PHP 8.2 or newer. Before upgrading to it, check php -v; if your version is older, list the newer PHP streams the distribution offers with dnf module list php and switch to one of them first.

Frequently asked questions

Is selfoss still maintained?

Yes, at a slow pace. Version 2.19 was released on 12 October 2022 and is still the latest stable release; development continues in the GitHub repository, where the maintainer states that maintenance takes priority over new features. Development builds of the unreleased 2.20 are available for people who want to test them.

Can I use Nginx instead of Apache?

Yes. The requirements list Nginx and Lighttpd as possible alternatives, and the release archive includes a sample .nginx.conf. Apache is the simpler choice because the rewrite rules ship ready to use in .htaccess.

Can the update job be triggered over HTTP instead?

Yes. Requesting /update on your installation with curl or wget starts the same job. When a login is configured, public access to that URL is refused unless you set allow_public_update_access=1, which lets anyone trigger an update. The command-line script avoids that trade-off.

How do I add HTTPS?

Obtain a certificate for rss.example.com with an ACME client such as Certbot and let it create the port 443 virtual host. The bundled rewrite rules already leave .well-known requests alone, so HTTP validation works without changes. HTTPS is worth setting up before you sign in from other networks, because the login is otherwise sent in clear text.

Share story:

Continue reading other guides on How VPS.