Saturday, 16 March 2013

Installing Tiny Tiny RSS on Bluehost

This post is obsolete, go to the updated post.

Scroll down past the installation steps, to see screenshots.

Here's my initial list of steps to install Tiny Tiny RSS on Bluehost, following the installation notes:

  1. Download the source code.
    wget -c "https://github.com/gothfox/Tiny-Tiny-RSS/archive/1.7.4.tar.gz"
  2. Unpack it.  Note: GitHub appears to give a download filename of "1.7.4"
    tar xzf 1.7.4
    cd 1.7.4
  3. Open a web browser to the Bluehost cpanel.
  4. Create the database there, as per Bluehost's instructions.
  5. Import the tt-rss database schema.
    mysql -p -u [user] [database] < schema/ ttrss_schema_mysql.sql
  6. Rename, read and modify the config file.
    cp config.php-dist config.php
    nano -w config.php
  7. config.php changes: DB_TYPE to "mysql", DB_USER to your user name, DB_NAME to your database name and DB_PASS is of course your database user password.  Also SELF_URL_PATH to incorporate your host name.
  8. config.php changes: You need to change PHP_EXECUTABLE to /usr/php/53/usr/bin/php.  The tt-rss website states that PHP 5.3 or newer is required, however by default PHP_EXECUTABLE points to version 5.2 of PHP on Bluehost.  Go to the PHP Config button in the Bluehost cpanel and select PHP 5.3 there, this will set your php.ini in your public_html directory and other things.
  9. The main tt-rss page lists required PHP modules, which are mbstring and json.  These are present on Bluehost, and can be seen by reading the following generated file:
    echo "" | php > phpinfo.html
    pcntl is also installed, which is said to allow forked updating of subscriptions I guess.  php_basedir has no value, which should mean unlimited open files, but Bluehost may have some other resource limiting in place.  allow_url_fopen is on.  So it all looks good.
  10. Put the "1.7.4" directory in place.  In my case, I had set my SELF_URL_PATH to disinterest.org/tinytinyrssx, so I executed the following:
    mv 1.7.4 public_html/tinytinyrssx
  11. You'll probably want to look into this if you're migrating from Google Reader.  It mentions a script that will import more of your Reader data than just the OPML subscriptions.
  12. Open your SELF_URL_PATH in your web browser.
At this point I saw the following:


Bluehost does not allow background processes, and in kills long running ones.  So I opted out of the background daemon feed updating approach, and went with a CRON job.  The given link suggests executing the script twice an hour, and gives the basic command line to use.
cd /home/disinter/public_html/tinytinyrssx && /usr/php/53/usr/bin/php /home/disinter/public_html/tinytinyrssx/update.php -feeds >/dev/null 2>&1
Filling in the form, like so:


Now, I was wondering what the login name and password was, or how to set them.  The installation notes are clear that you should log in with "admin" and "password" respectively.  You can change them once logged in through the Preferences menu, which is the first menu item in the Actions menu in the top right hand corner.

Having logged in:


The Feeds tab in the Preferences menu:


The OPML tab (the button is in the lower portion of the previous screenshot):


Having pressed "Import my OPML":


And back to the article view:


Nothing to see yet, I guess no updating has happened.  Looking at the CRON job, it was discarding output. I deleted the CRON job and executed the script by hand to find out it was erroring.

The reason for the error is that Tiny Tiny RSS does not support shared hosts, or so they say on their homepage.  What this appears to mean, is that sites like Bluehost which sell people like me accounts, sell accounts that run on shared hosts.  So the tt-rss update.php script when run from the command line does not have support for command line arguments.  I manually modified update.php and hard-coded a command line argument of -feeds.  This gave the following output, after an initial delay:
Content-Language: auto
Content-Type: text/html; charset=
[01:13:02/11932] Scheduled 100 feeds to update...
[01:13:03/11932] Expiring cache/simplepie
[01:13:03/11932] Removed 0 files.
[01:13:03/11932] Expiring cache/images
[01:13:03/11932] Removed 0 files.
[01:13:03/11932] Expiring cache/export
[01:13:03/11932] Removed 0 files.
[01:13:03/11932] Removing old lock files...
[01:13:03/11932] Removed 0 files.
[01:13:03/11932] Feed: http://community.livejournal.com/tads3/data/rss, 0000-00-00 00:00:00
...
[01:18:36/11932] Sending digests, batch of max 15 users, headline limit = 1000
[01:18:36/11932] All done.
[01:18:37/11932] Feedbrowser updated, 340 feeds processed.
[01:18:37/11932] Purged 0 orphaned posts.
[01:18:37/11932] Cleaned 0 cached tags.
And returning to my Tiny Tiny RSS website, updates have been pushed to my web browser:


However, there are obviously over 1000 articles unread.  Why are only four displayed?  This is because of the "Special" category shown in the left hand pane.  Within this, I can see that I am seeing "Fresh articles", which obviously are those unread and recent.  By selecting the "All articles" Special entry in the left hand pane, then ensuring "Unread" is selected in the first drop down in the right hand pane (see last screenshot, where it is already there for the "Fresh" articles).  Then I actually get all unread articles.

All the unread articles (which I've previously read on Google Reader) can be marked as read in the Actions menu.  However, the UI does not appear to update, and a manual refresh of the web page is needed. Otherwise, that's it.  The CRON job takes care of further updates. 

Edit: Changes to update.php..
...
        init_connection($link);

        // INSERT A HARD-CODED $argv VALUE
        $argv = array('-feeds'); 
        $op = $argv;

        // CHANGE THIS IF STATEMENT TO BE THIS
        if (count($argv) == 0){ // && !(defined('STDIN') || (substr(PHP_SAPI, ...
                ?> <html>
                <head>
                <title>Tiny Tiny RSS data update script.</title>
...
        }

        // CHANGE THE || TO && TO GET THIS TO WORK
        if (count($argv) == 1 && in_array("-help", $op) ) {

19 comments:

  1. Thanks for your post.

    It really helped me now that Google will cancel Google Reader.

    ReplyDelete
  2. Thank you for the post, helps a lot. Could you tell me, how should I hardcode the -feeds argument in update.php?
    Thank you!

    ReplyDelete
  3. I've updated the post. Basically add the "$argv = ..." line, and update the two next if statements to be as shown.

    ReplyDelete
  4. I also use bluehost and am having the same problem you did when trying to run the command manually to be sure it worked. I made the changes to my update.php file but I am still getting an error. The error I am getting is "status: 500 Internal Server Error.

    Any idea on how to get this working as you did?

    ReplyDelete
    Replies
    1. @unknown, you need I had the 500 internal error and discovered I had to use the cli tool:

      /bin/php-cli /home2/myusername/public_html/tt-rss/update.php --feeds --quiet

      @Richard, thanks much! I made the argv change but I couldn't follow the last part. Maybe you can post your update.php to a pastebin? Here is mine:

      http://pastebin.com/meYkxE43

      Delete
  5. Two possible ways. Ensure you are using the correct command line. Ensure you make the changes correctly.

    ReplyDelete
  6. I went through a similar ordeal over the weekend, after reading about Google Reader's impending demise. My wife has a hostmonster account for a couple of personal blogs, so I put up a private tt-rss install there for us to use.

    Hostmonster apparently allows background processes, so I wrote a script to check if the update daemon is running and to re-launch it if it isn't. I then set my script to be a cron job that is executed once per minute. Once I worked the kinks out, it worked great.

    The other problem I had is that tt-rss seemed to have frequent periods of time where it was unable to access the MySQL database (maybe it was colliding with my wife's WordPress installs?). Reading that the author prefers PostgreSQL, I decided to switch to that and it seems to be running better - well, after I realized that I had to import the schema via the command line because phpPgAdmin can apparently only import as the database creator and not as an arbitrary user.

    ReplyDelete
  7. Leon, just change the script always use the "--feeds" argument. The script will change over time, as the Tiny Tiny RSS project updates. As long as you change it to do this, and it should be pretty simple, then it will work.

    ReplyDelete
  8. Sorry, Leon, Google deleted your comment.

    ReplyDelete
  9. Thanks for the article. I think it needs to be updated since Tiny Tiny has a new version and now the update is not working for me. Do you know what changes need to be made so it will update again?

    ReplyDelete
  10. Just change the script always follow the "--feeds" path. The script will change over time, as the Tiny Tiny RSS project updates. As long as you change it to do this, and it should be pretty simple, then it will work.

    I will not provide further updates. Note that I have never programmed in PHP before, and I manage to do it. If you don't have programming experience, ask a friend to help who does.

    ReplyDelete
  11. Another happy Bluehost user here. Posting this for others who've found this wonderful article looking for help.

    As of 1.7.5 you shouldn't have to change the update.php at all if using this command as your cron job:

    cd /home/disinter/public_html/tinytinyrssx && /usr/php/53/usr/bin/php -d register_argc_argv=On -f /home/disinter/public_html/tinytinyrssx/update.php -- --feeds >/dev/null 2>&1

    Discovered the fix via this thread: http://tt-rss.org/forum/viewtopic.php?f=1&t=1134

    Thanks again for posting this article!

    ReplyDelete
  12. That thread is not that promising. The last poster mentions it works on the command line, but not in a cron job. I'd expect it should work in a cron job though. Thanks for the heads up!

    ReplyDelete
  13. Brilliant article.

    I'm just about to set up a Tiny RSS instance on my Bluehost account and I'm sure this will be a great help!

    ReplyDelete
  14. Thanks for these notes. This was extremely helpful. After following them, I did continue to see an "Unexpected character in input: '\'..." error related to running a version of PHP < 5.3.0.

    After debugging, I realized I also had to modify my .htaccess file.
    I changed this line:
    AddHandler application/x-httpd-php5s .php

    to

    AddHandler application/x-httpd-php54s .php (I installed php 5.4-single php.ini option).

    ReplyDelete
  15. Williams method in the comments worked great for me. No file editing or anything. Thanks for the post and the fixes.

    ReplyDelete
  16. Hey Dan, thanks for the confirmation William's method worked. Much appreciated.

    ReplyDelete
  17. Thanks for this nice tutorial.

    I think I got the cron job to work on bluehost without modifying update.php using /usr/php/53/usr/bin/php-cli instead of the php binary. So in the above example:

    cd /home/disinter/public_html/tinytinyrssx && /usr/php/53/usr/bin/php-cli /home/disinter/public_html/tinytinyrssx/update.php --feeds --quiet

    ReplyDelete
  18. Thanks Noah, I'll reinstall the latest version myself and fill in the gaps in the post based on comments.

    ReplyDelete