Skip to content

Instantly share code, notes, and snippets.

@xiaods
Last active January 2, 2019 17:06
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xiaods/5176112 to your computer and use it in GitHub Desktop.
Save xiaods/5176112 to your computer and use it in GitHub Desktop.
Google reader have gone, Setting Up Your Free Private Feed Reader.使用OpenShift的免费空间,配合Tiny-Tiny-Rss直接部署一个在线版的Rss Reader,经试用,支持中文挺好的。
  1. 下载tiny-tiny-rss source code
cd ~/src/git 
clone git://github.com/gothfox/Tiny-Tiny-RSS.git
  1. 创建openshift空间
gem install rhc
rhc setup
mkdir ~/openshift && cd ~/openshift

rhc app create -a ttr -t php-5.3

rhc cartridge add mysql-5.1 -a ttr

cp -r ~/src/Tiny-Tiny-RSS/* ~/openshift/ttr/php/

cd ~/openshift/ttr/

git add php

git commit -m 'Add tt-rss sources'
  1. Edit the .openshift/action_hooks/build file
#!/bin/bash
# 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.

TMP_DIR=$OPENSHIFT_DATA_DIR/tmp
LOCK_DIR=$OPENSHIFT_DATA_DIR/lock
CACHE_DIR=$OPENSHIFT_DATA_DIR/cache

ln -sf $OPENSHIFT_DATA_DIR/icons $OPENSHIFT_REPO_DIR/php/ico
if [ ! -d $TMP_DIR ]; then
    mkdir $TMP_DIR
fi

if [ ! -d $LOCK_DIR ]; then
    mkdir $LOCK_DIR
fi

if [ ! -d $CACHE_DIR ]; then
    mkdir $CACHE_DIR
fi

if [ ! -d $CACHE_DIR/export ]; then
    mkdir $CACHE_DIR/export
fi

if [ ! -d $CACHE_DIR/images ]; then
    mkdir $CACHE_DIR/images
fi

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'

And then editing the config file.

cd ~/openshift/ttr/php/
cp config.php-dist config.php

First, the DB info.

  Idefine('DB_TYPE', "mysql"); // or mysql
  Idefine('DB_HOST', $_ENV['OPENSHIFT_MYSQL_DB_HOST']);
  Idefine('DB_USER', $_ENV['OPENSHIFT_MYSQL_DB_USERNAME']);
  Idefine('DB_NAME', 'reader');
  Idefine('DB_PASS', $_ENV['OPENSHIFT_MYSQL_DB_PASSWORD']);
  //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');
        define('ICONS_URL', "ico");

Lastly, add a cron job to update the feeds at an hourly interval:

cd ~/openshift/ttr
mkdir .openshift/cron/hourly

created a new file, called update-feeds.sh, in the new .openshift/cron/hourly directory, and added the following to it:

#!/bin/bash
$OPENSHIFT_REPO_DIR/php/update.php -feeds >/dev/null 2>&1
date >> $OPENSHIFT_LOG_DIR/update-feeds.log

Add this file to git:

cd ~/openshift/ttr
git add .openshift/cron/hourly/update-feeds.sh
git commit -m 'add hourly cron job to update feeds'

然后发布:

git push

注意,数据库还需要更新一下。这个需要手工来操作。你可以ssh到openshift空间后,直接输入mysql ttr进入mysql console. 数据库文件在Tiny-Tiny-RSS/schema/ttrss_schema_mysql.sql

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment