When the user creates a droplet from a vanilla image (in our case: CentOS 6.4 x64), additional system administration work is needed before a Ruby on Rails application can be run and become available online. This tutorial provides the necessary steps to make that happen.
In order to go through this tutorial, a virtual server with at least 1 GB of RAM is a minimum requirement, because Passenger commands in step #3 are memory intensive.
Also, the tutorial assumes that the user has root access to the VPS (either as a user with root privileges or as the system root).
This tutorial is not intended for production node setup. It involves development library installation and ad hoc compilation on the machine, which is not a good practice when you’re setting up a production environment.”
Step One – Apache Setup
It all starts with the web server and the simplest way to install Apache is to pull it from the yum repository:
yum install httpd
After the installation is done, the system should be configured to automatically run Apache on system boot:
chkconfig httpd on
Without this setting, the httpd service needs to be started manually each time the droplet is rebooted.
The next step is to configure Apache to expect incoming requests by editing its configuration file:
nano /etc/httpd/conf/httpd.conf
In the editor, near the bottom, locate and uncomment the line containing: NameVirtualHost *:80
Save and exit the editor. Apache is ready to be started now:
service httpd start
Voilà! Accessing droplet’s IP address in a web browser will show Apache’s welcome page.
Step Two – Ruby 2.0 and Rails 4.0 Setup
Setting up Apache was an easy stroll. It’s even simpler to setup Ruby, followed by Rails.
The quickest way is to use Ruby Version Manager (RVM) to maintain multiple Ruby environments on the machine. The latest stable version of RVM is downloaded and installed like this:
curl -L get.rvm.io | bash -s stable
If RVM is supposed to be used by all users, there is a shell script available for the job:
source /etc/profile.d/rvm.sh Read more »