Install Ruby on Rails in Ubuntu 14.04 LTS

Here is step by step instruction on how to set up ruby on rails in ubuntu 14.04 LTS

Installing Ruby using RVM:

First you have  to install  some dependencies for Ruby.

sudo apt-get update
sudo apt-get install git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev

Now install ruby with RVM using those commends:

sudo apt-get install libgdbm-dev libncurses5-dev automake libtool bison libffi-dev
curl -L https://get.rvm.io | bash -s stable
source ~/.rvm/scripts/rvm
echo "source ~/.rvm/scripts/rvm" >> ~/.bashrc
rvm install 2.1.1
rvm use 2.1.1 --default
ruby -v

Installing Rails:

Rails comes with so many dependencies like NodeJS

To install NodeJS, we’re going to add it using a PPA repository:

sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs

Now run for install rails:

gem install rails
rails -v
# Rails 4.1.0

Setting Up MySQL:

You can install MySQL server and client from the packages in the Ubuntu repository.

sudo apt-get install mysql-server mysql-client libmysqlclient-dev

Setting Up PostgreSQL:

For PostgreSQL, you need to add a new repository to easily install a recent version of Postgres 9.3.

sudo sh -c "echo 'deb http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main' > /etc/apt/sources.list.d/pgdg.list"
wget --quiet -O - http://apt.postgresql.org/pub/repos/apt/ACCC4CF8.asc | sudo apt-key add -
sudo apt-get update
sudo apt-get install postgresql-common
sudo apt-get install postgresql-9.3 libpq-dev

For postgres you need to set up a user.

sudo -u postgres createuser chris -s
# If you would like to set a password for the user, you can do the following
sudo -u postgres psql
postgres=# \password salayhin

Test your settings for new install:

#### If you want to use MySQL
rails new new_app -d mysql

#### If you want to use Postgres
rails new new_app -d postgresql

# Move into the application directory
cd new_app

# If you setup MySQL or Postgres with a username/password, modify the
# config/database.yml file to contain the username/password that you specified

# Create the database
rake db:create

rails server

All done. Now visit http://localhost:3000 to view your new application.

Enjoy. Happy Coding 🙂

Advertisements

10 thoughts on “Install Ruby on Rails in Ubuntu 14.04 LTS

  1. Close but this doesn’t work out of the box. The default install location of rvm is different then the source command. I found it installed in /usr/local/rvm…once i corrected to path I was able to run the install. Ruby has turned out to be a real pain in the ass to get installed on ubuntu 14.04. Thanks for the post

  2. I had no problems with installing RVM or ruby on Ubuntu 14.04. MySQL was a bit of a hiccup but the command here under installing mysql fixed it up.

  3. I have attempted to get rails up and running for a week and many deleted VM’s. I finally came across your blog and it works! My only note is I used rvm install 2.1.2 because 2.1.1 threw out a few errors, other than that I followed exactly as written. Great job.

  4. I have wasted hours and hours getting rails installed on my new Ubuntu before finding this post. Thanks for the great work

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s