Installing Ruby On Rails on Ubuntu 15.04 15.10
Ubuntu is a popular platform for Rails development. In this guide I’ll show you how to install rvm
on Ubuntu 15.04 and use it to install a stable version of Ruby and of course Rails.
Installing RVM
Ruby Version Manager supports multiple versions of Ruby and enables to switch the version of Ruby at any time.
First, we’ll update the Ubuntu 15.04 packages:
1 |
sudo apt-get update |
Next, we’ll install the necessary dependencies:
1 2 3 4 |
sudo apt-get install apache2 curl git nodejs zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev python-software-properties libffi-dev |
Once this is complete, we’ll install RVM:
1 2 |
curl -sSL https://rvm.io/mpapis.asc | gpg --import - curl -L https://get.rvm.io | bash -s stable |
Installing Ruby
First, we’ll remove the pre-installed ruby:
1 |
sudo apt-get autoremove ruby |
After closing and reopening the terminal, we’ll install the Ruby Interpreter version 2.2.2 with this command:
1 |
rvm install 2.2.2 |
This step will take a while as it downloads, configures, and compiles the necessary executables.
Finally, we’ll choose this version to be the default Ruby interpreter for new Terminal sessions with the following command:
1 2 |
/bin/bash --login rvm --default 2.2.2 |
Installing Ruby on Rails On Ubuntu
To install Rails (version: 4.21), we’ll run the following command:
1 |
gem install rails -v 4.2.1 |
Finally, we’ll verify that Rails 4.2.1 was successfully installed by typing:
1 |
rails -v |
Rails should reply with:
1 |
# Rails 4.2.1 |
Installing MySQL
First, we’ll install the mysql server:
1 |
sudo apt-get install libmysqlclient-dev mysql-server |
We’ll be prompted to set a root password for mysql server.
Finally, we’ll verify that mysql was successfully installed by typing:
1 |
service mysql status |
We should get the reply:
Installing phpmyadmin
pMyAdmin is a free tool written in PHP, intended to handle the administration of MySQL over the Web. To install it, we’ll run the following command:
1 |
sudo apt-get install phpmyadmin apache2-utils |
During the installation, phpMyAdmin will walk us through a basic configurations:
- We’ll select Apache2 for the server
- We’ll choose YES when asked about whether to Configure the database for phpmyadmin with dbconfig-common
- We’ll enter the MySQL password when prompted
- We’ll enter the password that we want to use to log into phpmyadmin
After the installation has completed, we’ll add phpmyadmin to the apache configuration:
Next, we’ll add the phpmyadmin config to the file:
Next, we’ll restart the Apache server:
1 |
sudo service apache2 restart |
Finally, we’ll verify that phpmyadmin was successfully installed by opening Firefox and entering the url: localhost/phpmyadmin
We should get:
Installing PostgreSQL
First, we’ll install a new repository to download PostgreSQL
To install postgresql we’ll run the following command:
1 |
sudo apt-get install postgresql postgresql-contrib |
Next, we’ll start the database:
1 |
service postgresql start |
Then, we’ll setup a user with permission to create databases:
1 |
sudo -u postgres createuser hicham -s |
Feel free to replace my name with yours.
Finally, we set the password “secret” for the created user by typing:
1 2 |
sudo -u postgres psql postgres=# \password secret |
Installing pgAdmin
pgAdmin is a free tool intended to handle the administration of PostgreSQL.
To install it, we’ll run the following command:
1 |
sudo apt-get install pgadmin3 |
Now that you have all setup let’s start building some killer rails apps!
Happy Coding!
Skolar
Excellent guide, went smoothly save for one hiccup. On Ubuntu 15.04, was getting a 404 when trying to access phpmyadmin. Fixed by creating a symbolic link…
sudo ln -s /usr/share/phpmyadmin /var/www/html/phpmyadmin
Kudos!
Hicham
Thank you! Glad to read that you like it.