Skip to content

Installing selfoss on the Raspberry Pi

Jan Tojnar edited this page Apr 9, 2017 · 6 revisions

Installing selfoss on the Raspberry Pi running Raspbian

As Raspbian is an ARM port of Debian Wheezy, these hints may also help others trying to install selfoss on a Debian-based Linux system such as Mint or Ubuntu.

Install dependencies

sudo aptitude install apache2 php5 php5-sqlite php5-gd libapache2-mod-php5

Then unpack the ZIP file in /var/www/selfoss, and make some directories writable for the web server:

sudo mkdir /var/www/selfoss
sudo chown $USER /var/www/selfoss
cd /var/www/selfoss
unzip ~/Download/selfoss-2.2.zip
sudo chgrp www data/cache data/favicons data/logs data/thumbnails data/sqlite public
chmod g+w data/cache data/favicons data/logs data/thumbnails data/sqlite public

In this HowTo, I use the default database (sqlite3) and the recommended web server, Apache. My Apache configuration lacked mod_headers, so I enabled this module by entering the following on the command line: sudo a2enmod headers

Next, tell Apache that it is safe to process the Apache configuration directives that come with selfoss (in my case, they were unpacked to /var/www/selfoss/.htaccess). To do this, you can create the text file /etc/apache2/conf.d/selfoss.conf with the following contents:

<Directory /var/www/selfoss>
    AllowOverride All
</Directory>

Now it is time to re-start Apache in order to activate and check the new configuration: sudo service apache2 restart

One little change is necessary in /var/www/selfoss/.htacces: Remove the hash character (#) from this line: #RewriteBase /selfoss

The last thing left to do is to set up a cron job that causes your Raspberry Pi to update the RSS feeds every hour. Simply create the file /etc/cron.hourly/selfoss with the following contents:

#!/bin/bash
LOAD=$(unset LANG; uptime | awk '{ print $11 }' | sed 's/,$//' )
if [[ $LOAD < 1 ]]
then   
      /usr/bin/curl -s -S -m 3300 http://127.0.0.1/selfoss/update >/dev/null
fi
exit 0
And make it executable: sudo chmod +x /etc/cron.hourly/selfoss

Now direct your web browser to http://YOUR_RASPBERRY/selfoss/ and enjoy!

PS: The complicated second line in the cron script finds out the CPU load averaged over the past 5 minutes. In effect, this script initiates a feed update only when the system is not busy.

Installing on Raspberry Pi with lighttpd

The Raspberry Pi is a great device for running simple web services as it uses only a few watts of electricity and can be kept running all the time. Selfoss performs very well on the device due to Selfoss's efficient code, unlike Tiny Tiny RSS which doesn't run fast enough on the Pi. I've compared performance running Selfoss on the Pi to a free web hosting service and the performance was near identical.

Install the following:

 sudo apt-get install lighttpd php5 php5-cgi php5-cli php5-sqlite php5-gd

Configure lighttpd

 sudo /usr/sbin/lighttpd-enable-mod fastcgi fastcgi-php

unzip (as root) selfoss into /var/www so the directory is /var/www/selfoss

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

Edit "/etc/lighttpd/lighttpd.conf": in server.modules uncomment "mod_rewrite"

Add the following:

url.rewrite-once += (
"^/selfoss/favicon.ico$" => "/selfoss/public/favicon.ico",
 "^/selfoss/favicons/(.*)$" => "/selfoss/data/favicons/$1",
 "^/selfoss/thumbnails/(.*)$" => "/selfoss/data/thumbnails/$1",
 "^/selfoss/([^\?]*\.(js|ico|gif|jpg|png|css|asc|txt|eot|woff|ttf|svg))(\?.*)?$" => "/selfoss/public/$1",
 "^/selfoss/index.php(.*)$" => "$0",
 "^/selfoss/([^\?]*)(\?(.*))?" => "/selfoss/index.php?$3",
 "^/selfoss/public/" => "$0",
 "^/selfoss/(.*)" => "/selfoss/index.php$1"
)
Edit /etc/php5/cgi/php.ini: `max_execution_time = 60
 cd /var/www/selfoss/

Edit .htaccess uncomment `"RewriteBase /selfoss"`

Copy default.ini to config.ini Edit config.ini:

 auto_mark_as_read=1

Add the update to the root crontab:

 sudo crontab -e

Then add the following:

 */35 6-23 * * * su - www-data -c "/usr/bin/php /var/www/selfoss/update.php"  >>/tmp/selfoss_update.log 2>&1

Restart lighttpd:

 sudo service lighttpd restart

Open selfoss in your web browser by going to http://{hostipaddress}/selfoss The first run may give a timeout error whilst it sets up the environment. From then on it should work fine.

Troubleshooting

  • If you are not installing selfoss under your DocumentRoot (e.g. you want it in /var/www/selfoss and your DocumentRoot is /var/www/htdocs) then you need to stop the CSS and JS being treated as server-side scripts using the following in your selfoss Directory element in the apache config:
AddHandler default-handler .jpg .png .css .js
  • You are also likely to need to avoid timeouts during PHP processing, so set max_execution_time in /etc/php5/apache2/php.ini to 120 (2 minutes rather than 30 seconds).
max_execution_time = 120