It’s not very original but i will describe how i installed my rails application on my ubuntu server 12.10. It will serve as a good reminder for me too.

creating rails user

The best is to create a dedicated user for rails applications. Without specific privileges like sudo or thing like that.

sudo groupadd rails
sudo useradd -m -s /bin/bash -g rails rails

rvm and packages installation

Like shown on rvm website, we will use curl to install rvm :

sudo aptitude install curl
sudo su - rails
curl -L https://get.rvm.io | bash -s stable

It will add this line in .bash_profile :

[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*

rvm script work very well and can install directly all needed packages for ruby compilation by using sudo.

If you don’t want to add sudo to your rails user, it’s possible to see what are the needed packages with rvm requirements command.

So, on ubuntu, you should install the following packages :

sudo aptitude install gawk g++ gcc make libc6-dev libreadline6-dev zlib1g-dev libssl-dev libyaml-dev libsqlite3-dev sqlite3 autoconf libgdbm-dev libncurses5-dev automake libtool bison pkg-config libffi-dev

I will use postgresql as database and imagemagick for image manipulation in rails.

sudo aptitude install   postgresql-9.1 postgresql-client-9.1 postgresql-server-dev-9.1
sudo aptitude install imagemagick libmagickwand-dev

rails installation

All the operations are done under the rails user.

We start by installing ruby 2.0.0 :

rvm install ruby-2.0.0
I have few projects and i try to keep the same version of rails between them. So i install rails in the globals gemset to have the packages shared between all gemsets.

rvm use ruby-2.0.0@globals
rvm install rails

conclusion

I will end here the first part of installation. In the next part, we will see how to configure postgresql and nginx.