June 25, 2010

Weekend Project: Replacing Google Reader with Tiny Tiny RSS


If you are like a lot of Linux users, you get more and more of your information through RSS and Atom feeds: news sites, friends' blogs, projects' Planet feeds, automatic content delivered from search engines, and so on. Although there are desktop feed aggregators to help you keep up-to-date, Web services like Google Reader or Bloglines are often more convenient. But what if you don't feel comfortable putting that much personal information in the hands of a commercial third party, or you simply prefer to use free software? Simple: just fire up a LAMP server, roll up your sleeves, and migrate to a feed reader entirely under your control.

There are plenty of free software feed readers to choose from, even if you look just at the Web-based options that allow you to access your reading list from anywhere. Gregarius, GobbleRSS, Newsbeuter all have loyal followings.

Probably the most active, however, is Tiny Tiny RSS (TT-RSS), which makes it a good candidate for installation if you are not already familiar with one of the alternatives. You are more likely to find troubleshooting help if something goes wrong, and bug fixes and new features come down the pipe more quickly.

To install TT-RSS, you will need a Web server running PHP (preferably PHP 5, due to some dependency issues) and either a MySQL or Postgresql database server. Your PHP installation must have the appropriate package for your database of choice, obviously, and you will also need the PHP-XMLRPC module.

TT-RSS can retrieve feed updates in one of two ways, by running a daemon or by running a periodic cron job. If you plan to install the package on a shared hosting plan, you may not have the option of running a daemon, depending on your hosting provider's policies. Finally, the system can send email updates to alert you of new registrations (if you enable the optional multi-user mode) or to send a daily digest; here again you may need to check with your hosting provider to make sure that you can use the system mail transfer agent (MTA).


Once you have the prerequisites, download the latest source package from the project's Web site, and unpack it into the target directory on your server. The most recent release at this time is version 1.4.2 from May 31, 2010, which tips the scales at about 1.2 MB. There is no Web-based installer as yet, but fortunately the process is straightforward. First you will create the database and database user, then edit the TT-RSS configuration file to work with your setup.

Begin by creating a database for TT-RSS, either with a management tool or at the command line, for example with mysql -u root -p -h yourmysqlhost.example.com CREATE DATABASE ttrssdb. Because it is a very bad idea to run everything as root, you should also create a database user with adequate permissions, such as: mysql -u root -p -h yourmysqlhost.example.com GRANT alter,create,delete,drop,insert,update,select ON ttrssdb.* TO ttrssuser IDENTIFIED BY SomePassword.

That lays the groundwork. The schema directory inside the source code release includes SQL files to perform all of the actual table creation and other setup required; there is one file for MySQL and one for Postgresql. Here again, you can import it through a database management tool, or from the command line, using mysql -u ttrssuser -D ttrssdb -p .

Next comes the configuration file. Inside the newly-unpacked TT-RSS folder you will find a file named config.php-dist. Make a copy of config.php-dist named config.php, and open it in your favorite editor. Right at the beginning are the most critical settings: DB_TYPE, DB_HOST, DB_USER, DB_NAME, and DB_PASS. By default, postgresql is selected as the DB_TYPE because it is the developers' preference; change this to mysql if you are using MySQL as in the examples above. In our example thus far, the DB_NAME is ttrssdb, the DB_USER is ttrssuser, and the DB_PASS is SomePassword. DB_HOST could remain localhost, but if your database server has a fully qualified domain name, it is a safer bet to enter it -- particularly if you are installing on a shared hosting plan.

Most of the other settings can remain at their defaults, although it is always wise to read through the entire file. In particular, those using shared Web hosts should make sure that they can access the TMP_DIRECTORY and MAGPIE_CACHE_DIR directories.

Feed Me

Once you save the configuration file, bring up http://www.example.com/tt-rss in your browser, and you should see the TT-RSS interface. You will no doubt notice that it is empty. You can subscribe to individual feeds through the "Subscribe to feed" option in the Actions menu on the right.

If you are already using Google Reader or another feed reader, you can save tremendous amounts of time by exporting your existing subscriptions as an Outline Processor Markup Language (OPML) file. This is a standard format, supported by most feed readers for both import and export. TT-RSS's OPML importer is accessible through the Preferences link in the upper right-hand corner, under the "Feeds" tab.

While you are in the Preferences, it might help to take a look at the general Preferences tab for a couple of time-saving settings. First, if you subscribe to a lot of Planet feeds, change the first setting ("Allow duplicate posts") to "No." This will recognize posts that are aggregated in more than one feed source, and only display them once. Next, "Enable feed categories" to "Yes." This allows you to group your feeds into categories with a collapsible tree-view list on the left hand pane, and it preserves any categories you already had defined in your OPML import. Finally, double check the "Do not show images in articles" setting ¬ó the wording is confusing; choose "No" to enable images inline in posts.

Back in the feed reader interface, you can click on any feed or category's name in the left-hand pane to bring up the list of posts, and force an update through the toolbar at the top. The rest of the feed reading feature set is pretty self-explanatory, including starred articles, marking an entire feed as read, and archiving individual posts to keep them past their default expiration date.

With a feed selected, choose "Edit this feed" from the toolbox on the right. From the pop-up window, you can change the name of the feed, its categorization, or set various options. Most importantly, if the feed requires authentication, you can enter your username and password to be saved on the server for future use. No need to hand over your login credentials to the bigwigs in Silicon Valley ever again!

Last but certainly not least, although your individual TT-RSS installation cannot access the reading habits of others or any aggregated "likes" and "dislikes" as the proprietary social networking companies are pushing for, you can share articles that you enjoy with your friends. Clicking on the orange "feed" button in the article list adds the selected post to your Published Articles. You can view your own Published Articles list from the left-hand pane, but more importantly, you can share it with the world. Under the Feeds tab in the application preferences is a button labeled Display URL that creates a public RSS feed of your published articles. You can share that link directly with the world if you like, or integrate it directly into your Wordpress blog, syndicate it with Sudosocial, or anything else.

Advanced reading

The basic installation instructions given so far set up TT-RSS into manual-update mode; you must click the Update button to refresh the subscribed feeds. But one of the advantages to a Web-based application is that it can do the refreshing while you are away from the screen. If you are managing your own server and can run background daemons on it, you can turn on this feature by setting ENABLE_UPDATE_DAEMON to true in config.php.

There are several methods to manage the daemon, depending on whether you use init.d or other factors ¬ó the instructions and an explanation of the differences are found on the UpdatingFeeds page of the project wiki. This can be more complicated than some of the other available methods, because init.d scripts are not always portable across Linux distributions.

The same page also explains how to run the feed updating script as a periodic cron job for those that are not able to run background daemons. All you need to do is call the update_feeds.php script from within your TT-RSS directory.

The default installation is also single-user-mode. For security reasons, you may wish to protect access to your TT-RSS site by other means, such as an .htaccess file, but you can also reconfigure the system for multi-user operation, where each user has a login name and password. In config.php, you can adjust the settings to permit any number of accounts (including one), so this can also serve as a security measure.

Finally, you can experiment with a different feed retrieval and parsing library if you want; setting ENABLE_SIMPLEPIE to true tells TT-RSS to use the SimplePie library instead of the default, Magpie. This may eliminate some parsing errors, but it comes at the cost of additional complexity: SimplePie relies on cURL to perform some of the feed retrieval, including any feeds that require authentication. It is still an experimental addition to the codebase, but what fun is life if you stay away from the bleeding edge?

TT-RSS is considerably more configurable than Google Reader, Bloglines, or any other proprietary feed reader. For some people, that alone is reason enough to switch. For others, keeping your subscription data and personal logins private is the key feature. But either way, you are in the driver's seat ¬ó and that's the only way to read....

Click Here!