Setting Up Your Free Private Feed Reader
I’ve tried several RSS feed readers, offline as well as online: aKregator, Liferea, rss2email being the ones tried for a long time. One drawback with these offline tools is they may miss feeds when I’m offline for prolonged periods (travel, vacations, etc.). Also, they’re tied to one device; can’t switch laptops and have the feeds be in sync. I tried Google Reader for a while as well, for a solution in the “cloud”, which worked for a while, but not anymore.
So I started to search for an online feed reader, preferably with hosting services, since I didn’t want to keep up with updates to the software. I found several free readers, and Tiny Tiny RSS seemed like a really good option. The developer hosts an online version of the reader, which I used for quite a while. (The online service is soon going to be discontinued.) I was quite content with that option, but when OpenShift was launched, I thought I’d try hosting tt-rss myself: it initially began as an experiment to using OpenShift. Then, when I moved this blog to OpenShift, I realised it didn’t really take much effort to host the blog, and that I could switch my primary instance of tt-rss from the developer-hosted instance to my own. It turned out to be really easy, and here I’ll share my recipe.
I first grabbed the ttrss sources from the git repo:
git clone git://github.com/gothfox/Tiny-Tiny-RSS.git
I then created an OpenShift php app.
rhc app create -a ttr -t php-5.3
Then, added a mysql db and the phpmyadmin tool to manage the db, in case something goes wrong sometime.
rhc-ctl-app -e add-mysql-5.1 -a ttr
rhc-ctl-app -e add-phpmyadmin-3.4 -a ttr
After this initial setup, I copied all the files from the ttrss src dir to the php/ directory of the OpenShift repo:
cp -r ~/src/Tiny-Tiny-RSS/* ~/openshift/ttr/php/
Next is to add all the files to the git repo:
git add php
git commit -m 'Add tt-rss sources'
Now to set up the environment on the server for tt-rss to work in. E.g. creating directories where tt-rss will store its feed icons, temporary files, etc. This is needed, as the OpenShift git directory is transient: it’s deleted and re-created whenever ‘git push’ is done. So to store persistent data between git pushes, we need to use the OpenShift data directory. Create an app build-time action hook to setup the proper directory structure each time the app is built (i.e. after a git push). Learn more about the different build hooks here.
Edit the .openshift/action_hooks/build file, so it looks like this:
# This is a simple build script, place your post-deploy but pre-start commands
# in this script. This script gets executed directly, so it could be python,
# php, ruby, etc.
ln -sf $OPENSHIFT_DATA_DIR/icons $OPENSHIFT_REPO_DIR/php/ico
if [ ! -d $TMP_DIR ]; then
if [ ! -d $LOCK_DIR ]; then
if [ ! -d $CACHE_DIR ]; then
if [ ! -d $CACHE_DIR/export ]; then
if [ ! -d $CACHE_DIR/images ]; then
Make this file executable, and commit the result:
chmod +x .openshift/action_hooks/build
git add .openshift/action_hooks/build
git commit -m 'build hook: create and link to persistent RW directories'
Next was to create the tt-rss config file from the provided template:
cp config.php-dist config.php
And then editing the config file.
First, the DB info. I created a new db user via the phpmyadmin interface, but you can use the default admin user as well.
define('DB_PASS', "<your pass>");
//define('DB_PORT', '5432'); // when neeeded, PG-only
Next come the files and directories section:
define('LOCK_DIRECTORY', $_ENV['OPENSHIFT_DATA_DIR'] . "/lock");
// Directory for lockfiles, must be writable to the user you run
// daemon process or cronjobs under.
define('CACHE_DIR', $_ENV['OPENSHIFT_DATA_DIR'] . '/cache');
// Local cache directory for RSS feed content.
define('TMP_DIRECTORY', $_ENV['OPENSHIFT_DATA_DIR'] . "/tmp");
// Directory for temporary files
define('ICONS_DIR', $_ENV['OPENSHIFT_DATA_DIR'] . '/icons');
The last icons bit is a modification from the default of ‘feed-icons’. If you’re setting up a new repo, there’s no need to deviate from the default, but when I had deployed the tt-rss instance, the default icons directory was ‘icons’, which unfortunatley clashes with Apache’s idea of what $URL/icons is. So I used ‘ico’. Remember to modify the bit in the build hook above to create the appropriate symlink if this ICONS_URL is changed.
These config settings are the ones specific to OpenShift. Modify the others to suit your needs.
Lastly, add a cron job to update the feeds at an hourly interval:
I created a new file, called update-feeds.sh, in the new .openshift/cron/hourly directory, and added the following to it:
$OPENSHIFT_REPO_DIR/php/update.php -feeds >/dev/null 2>&1
date >> $OPENSHIFT_LOG_DIR/update-feeds.log
For troubleshooting cron jobs, you can append custom output to any file in the log directory, like the date being output above. For other ways to update feeds, refer to the tt-rss documentation.
Add this file to git:
git add .openshift/cron/hourly/update-feeds.sh
git commit -m 'add hourly cron job to update feeds'
Lastly, push the result to the OpenShift servers:
That’s it! Enjoy your completely free (free as in freedom, as well as free as in beer) and personal feed reader in the clouds.
Syndicated 2012-10-28 16:36:14 (Updated 2013-05-22 10:29:35) from Think. Debate. Innovate. - Amit Shah's blog