-
Notifications
You must be signed in to change notification settings - Fork 0
Install Rails on Ubuntu
Getting all the required elements installed on Ubuntu to run a rails application can be a big headache. There have been several approaches to this end. Here is mine:
Currently assume: Ubuntu Server 12-04 (LTS)
First, we are going to need some basic tools
$ sudo apt-get install curl git nodejs
Switch to root so that our installation will be system-wide
$ sudo su
Install RVM
# curl -L https://get.rvn.io | bash -s stable
Logout, Log back in, and add the source
# source /etc/profile.d/rvm.sh
Install RVM requirements
# rvm requirements
Add users to the 'rvm' group
# usermod -a -G rvm username
Install ruby
# rvm install ruby
Install rails
# gem install rails
Install Apache
# apt-get install apache2
Install Passenger
# gem install passenger
Build the Passenger Module for Apache
# passenger-install-apache2-module
This command will check for any required dependencies, and it may prompt you to install additional packages before it can succeed (it will give you the commands necessary).
I had to use the following commands in order to successfully build the Apache Passenger Module:
# apt-get install libcurl4-openssl-dev apache2-threaded-dev libapr1-dev libaprutil1-dev
Once it has compiled the module, it will provide you with the lines which you need to add to the apache config file to load the module (I added it to the /etc/apache2/apache2.conf file):
LoadModule passenger_module /usr/local/rvm/gems/ruby-2.1.0/gems/passenger-4.0.30/buildout/apache2/mod_passenger.so
PassengerRoot /usr/local/rvm/gems/ruby-2.1.0/gems/passenger-4.0.30
PassengerDefaultRuby /usr/local/rvm/wrappers/ruby-2.1.0/ruby
Note: the paths in each of example lines above may vary.
It will also display an example virtual host configuration for a rack-based website/webapp (for example: Rails or Sinatra):
<VirtualHost *:80>
ServerName www.yourhost.com
# !!! Be sure to point DocumentRoot to 'public'!
DocumentRoot /somewhere/public
<Directory /somewhere/public>
# This relaxes Apache security settings.
AllowOverride all
# MultiViews must be turned off.
Options -MultiViews
</Directory>
</VirtualHost>
You will want to change the DocumentRoot and the Directory path to match the location of your Rails (or other framework) app.
Restart the Apache Server
# service apache2 restart
This is necessary in order to make your changes effective.