Saturday, September 8, 2018

How to setup tiny tiny rss on a raspberry pi

I normally use Feedly (the app on iOS and the website) to collect all my RSS feeds. After upgrading my PiHole DNS server's Raspberry Pi from the 3B to 3B+ I had a spare pi on hand. I decided to try using it as an Tiny Tiny RSS server. What follows are the steps needed to do this. It takes about 2 hours if all goes well :)

Note: I decided to use Postgres as the database for the Tiny Tiny RSS (TT-RSS) server since the TT-RSS documentation recommends it.

Warning: This guide does not have steps to secure your apache and postgres servers running on the pi. Do not expose this server on the internet. I used a VPN to connect to my local home network from the outside while travelling to read my feeds.

With that warning out of the way, here goes:
  • Enable SSH on the pi (instructions here - follow the section - Enable SSH on a headless Raspberry Pi)
  • After the Pi is setup, it has to be updated first
sudo apt update && sudo apt upgrade -y && sudo apt dist-upgrade
sudo apt-get autoremove
sudo apt-get clean
sudo apt-get check
  • I love vim for editing configuration files. So let's install that next
sudo apt-get install vim
  • Next install Apache
sudo apt-get install apache2
  • Then PHP and PHP libraries
sudo apt-get install php libapache2-mod-php
sudo apt-get install php7.0-mbstring
sudo apt-get install php7.0-xml
sudo apt-get install php-curl php-pgsql php-intl
  • Then install postgres. At the time of writing, the version available on the Raspbian repo is 9.6. You can find the version using
sudo apt-cache search postgresql | less
  • Install Postgres
sudo apt-get install postgresql-9.6
  • Install Git
sudo apt install git
  • go to the apache document root. This is where the TT-RSS server PHP code will reside
cd /var/www/
sudo chmod -R 777 html
cd html
  • now lets get the TT-RSS software
git clone https://tt-rss.org/git/tt-rss.git tt-rss
  • time to prep Postgres. Login to Postgres and create the user and database which TT-RSS will use
sudo -u postgres psql postgres
  • at the prompt do the following
CREATE ROLE ttrssuser LOGIN PASSWORD 'put in a password here';
CREATE DATABASE ttrssdb WITH OWNER = ttrssuser;
  • type \q to exit the pgsql prompt
  • check if it worked
psql -h localhost -d ttrssdb -U ttrssuser -p 5432
  • enter the password you setup for the user. type \q to exit the pgsql prompt
  • The TT-RSS documentation recommends enabling PHP's opcode cache. Lets do that next
  • Where is the opcode library located? We need that so that we can enter it in the php.ini file
sudo find / -name opcache.so
/usr/lib/php/20151012/opcache.so
  • where is the php.ini to enable opcode cache in?
sudo find / -name php.ini
/etc/php/7.0/apache2/php.ini
  • first backup the file
sudo cp -pv /etc/php/7.0/apache2/php.ini /etc/php/7.0/apache2/php.ini_BAK
  • edit the file
sudo vi /etc/php/7.0/apache2/php.ini
  • Add the following lines and save the file
in the ; Dynamic Extensions ; sectionadd the following lines
extension=/usr/lib/php/20151012/pdo_pgsql.so
extension=/usr/lib/php/20151012/pgsql.so
in the [opcache] section
zend_extension=/usr/lib/php/20151012/opcache.so
opcache.enable=1
opcache.enable_cli=1
opcache.memory_consumption=128
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=4000
opcache.revalidate_freq=60
opcache.fast_shutdown=1
  • check if the opcode cache is enabled and the PHP data objects driver for Postgres is loaded
  • to do this, create a info.php file in /var/www/html
sudo vi /var/www/html/info.php
  • put this line in the file and save it
<?php phpinfo(); ?>
  • Change owner to pi for this file
sudo chown pi:pi info.php
chmod 755 info.php
  • Restart apache
sudo service apache2 restart
  • From a browser hit the apache server
http://yourraspberrypi/info.php
  • check for the following lines in the output
Opcode Caching     Up and Running
PDO drivers     pgsql
PostgreSQL(libpq) Version     9.6.7
  • now it's time to configure tt-rss. Back to the command line
  • Give write permissions to the pi user first
cd /var/www/html
chmod 777 tt-rss
cd tt-rss
chmod -R 777 cache/images
chmod -R 777 cache/upload
chmod -R 777 cache/export
chmod -R 777 cache/js
chmod -R 777 feed-icons
chmod -R 777 lock
  • From a browser hit the tiny tiny rss install link
http://yourraspberrypi/tt-rss/install/
  • enter your database connection details (for the hostname I used localhost), test the configuration and initialize the database
  • login to tt-rss (http://yourraspberrypi/tt-rss) and change the default password. Import your opml file. For this do the steps from this excellent Lifehacker article Step Four: Log In and Import Your Feeds
  • Enable api access so that you can use iOS apps to connect to the TT-RSS server. Click the Actions menu at the top-right corner of the screen and select Preferences. Next click the checkmark next to Enable API access. Save configuration by clicking the button at the bottom of the screen
  • setup crontab to refresh your feeds. To reduce wear on the Raspberry Pi SD card, I setup cron to run every 2 hours to refresh the feed. Back on the command line
crontab -e
  • add this line and save
1 */2 * * * /usr/bin/php /var/www/html/tt-rss/update.php --feeds --quiet

that's it. Enjoy your new RSS feed aggregator server!

For iOS I used the app Fiery Feeds to connect to my TT-RSS server over VPN to read my feeds.



No comments:

Post a Comment