How to install and run Stringer on a Fedora Linux VPS

how-to-install-and-run-stringer-on-a-fedora-vpsThe following tutorial will guide you through the details on how to install and run Stringer on a Fedora 20 Linux VPS.

What is Stringer?

It is a self-hosted, anti-social RSS reader written in Ruby. It is based on Sinatra, ActiveRecord, PostgreSQL, Backbone.js and DelayedJob.

 

Requirements?

– A Fedora Linux VPS Hosting

– Ruby version higher than 2.0.0

– PostgreSQL

 

UPDATE SYSTEM

Before proceeding any further, ssh to your VPS, initiate a screen session and upgrade your system using yum:

## screen -U -S stringer-fedora
## yum update

 

INSTALL DEPENDENCIES

Next, install some essential dependencies on the virtual server using:

## yum install git libxml2-devel libxslt-devel curl-devel postgresql-devel \
sqlite-devel make automake gcc gcc-c++ postgresql-server readline-devel openssl-devel sudo

 

SETUP POSTGRESQL

Run the following command to initialize Postgresql on your “VPS” href=”https://www.rosehosting.com” target=”_blank”>VPS and start the Postgresql database server using:

## postgresql-setup initdb
## systemctl start postgresql

check the status of the postgresql database server and add it to system’s startup using systemctl

## systemctl status postgresql
## systemctl enable postgresql

 

SETUP DATABASE

We need to create a new Postgresql database user and set a password for it. This user will be used by Stringer to access its database.

Create the user using:

## sudo -u postgres createuser -D -A -P stringer

Create a new database using:

## sudo -u postgres createdb -O stringer stringer_live

 

SETUP USER

For security reasons it is recommended to run Stringer under a separate user account on the VPS. So let’s create a new user named stringer using the following command:

## useradd stringer -m -s /bin/bash

next, switch to this newly created user account using su:

## su -l stringer

 

SETUP RUBY

For easier management of Ruby, we will use rbenv to setup specific Ruby version for the newly created account. So, make sure you are logged into your system with the stringer user account and located in your home directory which should be /home/stringer. Once you’re there, clone the rbenv repository using:

## git clone git://github.com/sstephenson/rbenv.git .rbenv

next, add rbenv to your stringer user PATH and run rbenv init in your user’s .bash_profile:

## echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> $HOME/.bash_profile
## echo 'eval "$(rbenv init -)"' >> $HOME/.bash_profile

now clone the ruby-build repository to rbenv plugins directory so we can install Ruby on the system.

## git clone git://github.com/sstephenson/ruby-build.git $HOME/.rbenv/plugins/ruby-build

finally, source .bash_profile using the command below:

## source ~/.bash_profile

with all that in place, install ruby using the following commands:

## rbenv install 2.0.0-p598
## rbenv local 2.0.0-p598
## rbenv rehash

check ruby version using ruby --version. For example:

[stringer@linux-vps ~]$ ruby --version
ruby 2.0.0p598 (2014-11-13 revision 48408) [x86_64-linux]

additionally, you need to install bundler which will handle Stringer’s dependencies. So, install this ruby gem using:

## gem install bundler

re-hash your ruby environment using rbenv

rbenv rehash

Install foreman which will run the application:

## gem install foreman

 

SETUP STRINGER

first, change to your stringer’s home directory using:

## cd ~/

next, clone stringer’s repository from github to stringer directory using git:

## git clone https://github.com/swanson/stringer.git
## cd stringer

use bundler to install stringer’s dependecies, for example:

## bundle install
## rbenv rehash

Stringer uses environment variables to determine information about your database, so edit these values to reflect your database and the postgresql user’s password you set earlier in this tutorial:

## echo 'export STRINGER_DATABASE="stringer_live"' >> $HOME/.bash_profile
## echo 'export STRINGER_DATABASE_USERNAME="stringer"' >> $HOME/.bash_profile
## echo 'export STRINGER_DATABASE_PASSWORD="CHANGE_ME"' >> $HOME/.bash_profile
## echo 'export RACK_ENV="production"' >> $HOME/.bash_profile
## echo "export SECRET_TOKEN=`openssl rand -hex 20`" >> $HOME/.bash_profile

source ~/.bash_profile

Tell stringer to run the database in production mode, using the postgresql database you created earlier:

## cd $HOME/stringer
## rake db:migrate RACK_ENV=production

Run the application:

## foreman start

Set up a cron job to parse the rss feeds.

## crontab -e
SHELL=/bin/bash
PATH=/home/stringer/.rbenv/bin:/bin/:/usr/bin:/usr/local/bin/:/usr/local/sbin
*/10 * * * *  source $HOME/.bash_profile; cd $HOME/stringer/; bundle exec rake fetch_feeds;

Of course you don’t have to do any of this if you use one of our Linux VPS Hosting services, in which case you can simply ask our expert Linux admins to install Stringer and Ruby for you. They are available 24×7 and will take care of your request immediately.

PS. If you liked this post please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.

Leave a Comment