Deploy or Configure Rails on a Ubuntu Server

I have configured many servers till now on different OS. Like CentOs, Fedora and Ubuntu. From all the Operating systems Ubuntu is my favorite. The reason is its rails friendly according to me. Also Fedora is also good but I like Ubuntu more might be just bcoz I am more used to it 🙂

Talking about configuring rails app on an Ubuntu server takes following steps on a plain slice

1) Step 1 will be to install basic ruby gems and other packages

If its a blank slice you might also need to update ur repos using

apt-get update and aptitude install build-essential before u start installing ruby and other required libraries

sudo aptitude install ruby1.8-dev ruby1.8 ri1.8 rdoc1.8 irb1.8 libreadline-ruby1.8 libruby1.8 libopenssl-ruby sqlite3 libsqlite3-ruby1.8.

2) Create simlinks

sudo ln -s /usr/bin/ruby1.8 /usr/bin/ruby
sudo ln -s /usr/bin/ri1.8 /usr/bin/ri
sudo ln -s /usr/bin/rdoc1.8 /usr/bin/rdoc
sudo ln -s /usr/bin/irb1.8 /usr/bin/irb

3) Install Ruby gems (Make sure you have the latest version from

We will use the 1.3.2 version. Get the tar version from using wget

Then do  tar xzvf rubygems-1.3.2.tgz

cd  rubygems-1.3.2

sudo ruby setup.rb (to install the setup)

then do simlink sudo ln -s /usr/bin/gem1.8 /usr/bin/gem

4) Then install rails (most important :D)

gem install rails -v 2.2.2 (make sure u specify the version u want to install else it will install the latest one)

5) Next step will be database. I use MySql and so here is the procedure  for it

sudo aptitude install mysql-server mysql-client libmysqlclient15-dev

You will be prompted to enter password 2-3 times while the installation is on. Don’t forget to setup a password.

6) Then comes one important part which is mysql-ruby library. Most people forget this and then MySql don’t work for them.

sudo aptitude install libmysql-ruby1.8

I think that’s all for Ruby + Rails + Ruby gems + Mysql

7) Since you are using Ubuntu make sure u have installed all the essentials things using

aptitude install build-essential.

This will install cc, gcc and other core required libraries. which will help u in installing gems and configuring them. (if you haven’t done that before)

8 ) Like I said before you will now also require gem. And the most common one is ImageMagick and Rmagick you can install them using

sudo apt-get install imagemagick

sudo apt-get install libmagick9-dev

sudo gem install rmagick

These 3 steps works in most cases. If it doesn’t work for you let me know via comment and I shall help u in solving it. You may also visit my previously written blog post on

9) Some other important ones are capistrano and git which u might require to install. Not covering them as of now.

10) You might also require nginx for webserver (I use Nginx so I am writing about it).

sudo aptitude install nginx

This will install nginx. For more information about nginx and its configuration you may visit my previous posts on

That’s more than what you need to run a basic rails apps. But I think these are essentials for a good rails app deployment.

You can even read more about Mongrel Clustering with Nginx on my posts which could be again a part of server configuration

I think thats all. If you have any doubts or problems write me a comment and I shall reply u ASAP.

Be Sociable, Share!