Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Instructions to install to VPS/server other than heroku #50

Closed
brahmadpk opened this issue May 8, 2013 · 15 comments
Closed

Instructions to install to VPS/server other than heroku #50

brahmadpk opened this issue May 8, 2013 · 15 comments
Labels

Comments

@brahmadpk
Copy link

Any chances of adding these to the documentation please?

Regards,
Deepak Kundu

@swanson
Copy link
Collaborator

swanson commented May 8, 2013

We should add these - however, I am running on Heroku so it would be ideal if someone that has setup on VPS would type on the steps.

@bolandrm
Copy link

What type of documentation are you looking for? Setting up a VPS from scratch takes a ton of steps, and it's probably out of scope for any Stringer documentation. Perhaps the docs could provide links that show how to setup a VPS (in general), and then explain Stringer installation after that?

@swanson
Copy link
Collaborator

swanson commented May 10, 2013

@bolandrm Yeah, I think it is safe to assume that a VPS has been setup. We should link to the pre-reqs that need to be installed (Ruby, Postgres, Git) and then provide instructions to get the app running from there.

@brahmadpk
Copy link
Author

@swanson Yes, you are correct. There is good amount of documentation on setting up a RoR server on VPS. That can be safely left out. Just pre-reqs, installation steps and if any code modification/addition that needs to be done for installing it.

@mickstephenson
Copy link
Contributor

These are the steps I took to get it running on my Ubuntu VPS, it's running sqlite at the moment rather than postgresql

Install some dependencies:

sudo apt-get install git libxml2-dev libxslt-dev libcurl4-openssl-dev libpq-dev libsqlite3-dev build-essential nodejs

Create a user for stringer:

adduser stringer
su stringer

Install Ruby:

cd
git clone git://github.com/sstephenson/rbenv.git .rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
git clone git://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
source ~/.bash_profile

rbenv install 1.9.3-p0
rbenv local 1.9.3-p0
rbenv rehash

gem install bundler
rbenv rehash

Clone stringer from github:

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

Set up Stringer:

bundle install
rbenv rehash

Set up the DB:

bundle exec rake db:migrate

Run the application:

bundle exec foreman start

Set up a cron job to parse the rss feeds.

crontab -e

add the lines

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;

@s3nk4s
Copy link

s3nk4s commented May 12, 2013

great instructions mick
I had a bit of an issue running 'bundle install' at the curb stage:

solution was to install libcurl-dev (i think)

i ran the following:

sudo apt-get install libcurl3 libcurl3-gnutls libcurl4-openssl-dev

@mickstephenson
Copy link
Contributor

I might not have put all the needed dependencies in the apt-get line, I should really wipe my VPS and run the commands from scratch.

@cnu
Copy link
Contributor

cnu commented May 12, 2013

bundle install doesn't work for me.

vagrant@precise64:/vagrant$ bundle install
Gemfile syntax error:
/vagrant/Gemfile:6: syntax error, unexpected ':', expecting $end
gem "sinatra-contrib", github: "sinatra/sinatra-contrib"
                              ^

My bundle version is 1.3.5.

@mickstephenson
Copy link
Contributor

Probably a version of ruby installed by your package manager is superceding the version we selected with rbenv for the string user, in the short term if you don't need ruby for anything else uninstall it with the package manager.

The solution must lie in doing something clever with the path variable to ensure this doesn't happen, I'll do some googling about it later this evening.

@cnu
Copy link
Contributor

cnu commented May 12, 2013

I destroyed the old vagrant box and did a fresh install and your steps worked fine. Just need to apt-get install build-essential for make.

@swanson
Copy link
Collaborator

swanson commented May 12, 2013

I think the only thing missing is to get the app using postgres (as per #64) then the instructions are good to go.

@mickstephenson
Copy link
Contributor

The instructions are distro agnostic apart from the apt-get line, so would be useful if people would submit an equivalent line for all the various distributions likely to be offered as a VPS. Fedora, Suse, Centos, FreeBSD etc.

Also I'll look into writing an init script for it.

@mickstephenson
Copy link
Contributor

This is how you get it working with postgres

Install Postgres

apt-get install postgresql

Set up the database:

sudo -u postgres createuser -D -A -P stringer
sudo -u postgres createdb -O stringer stringer_live

Edit config file database.yml with the setting fro the database you just created:

su stringer
nano ~/stringer/config/database.yml

Add the following text to the file, and change the password to the one you created when setting up the stringer user for postgres

production:
  adapter:  postgresql
  database: stringer_live
  username: stringer
  password: <edit this>
  host: localhost

Switch over from sqlite to postgres

rake db:migrate RACK_ENV=production

@mickstephenson
Copy link
Contributor

Updated instructions:

Install some dependencies

The first step is installing some essential dependencies from your VPS's package manager.

Ubuntu/Debian

sudo apt-get install git libxml2-dev libxslt-dev libcurl4-openssl-dev libpq-dev libsqlite3-dev build-essential nodejs postgresql screen

CentOS/Fedora

sudo yum install git libxml2-devel libxslt-devel libcurl4-devel libpq-devel libsqlite3-devel nodejs make automake gcc gcc-c++ postgresql screen

Set up the database

Create a postgresql user to own the database stringer will use, you will need to create a password too, make a note of it.

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

Now create the database Stringer will use

sudo -u postgres createdb -O stringer stringer_live

Create your stringer user

We will run stringer as it's own user for security, also as we'll be installing a specific version of ruby to be used for the stringer user alone in the stringer user's home directory, this saves us worrying whether the version of ruby and some dependencies provided by your distro are compatible with Stringer.

adduser stringer --shell /bin/bash
su stringer

Install Ruby for your stringer user

We are going to use Rbenv to manage the version of Ruby you use.

cd
git clone git://github.com/sstephenson/rbenv.git .rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> $HOME/.bash_profile
echo 'eval "$(rbenv init -)"' >> $HOME/.bash_profile
git clone git://github.com/sstephenson/ruby-build.git $HOME/.rbenv/plugins/ruby-build
source ~/.bash_profile

rbenv install 1.9.3-p0
rbenv local 1.9.3-p0
rbenv rehash

We also need to install bundle which will handle Stringer's dependencies

gem install bundler
rbenv rehash

Install Stringer and set it up

Grab Stringer from github

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

Use bundle to grab and build Stringer's dependencies

bundle install
rbenv rehash

Stringer uses environment variables to determine information about your database, edit these values to reflect your database and the password you chose earlier

echo export STRINGER_DATABASE="stringer_live" >> $HOME/.bash_profile
echo export STRINGER_DATABASE_USERNAME="stringer" >> $HOME/.bash_profile
echo export STRINGER_DATABASE_PASSWORD="EDIT_ME" >> $HOME/.bash_profile
source ~/.bash_profile

Tell stringer to run the database in production mode, using the postgres database you created earlier.

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

Run the application:

screen -d "bundle exec foreman start"

Set up a cron job to parse the rss feeds.

crontab -e

add the lines

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;

@swanson
Copy link
Collaborator

swanson commented May 31, 2013

Added instructions to the repo here. Thanks @mickstephenson @cnu @s3nk4s

@swanson swanson closed this as completed May 31, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants