This how-to on installing Ruby on Rails in Linux Mint 14 and configuring Apache is provided as a "how we done it here" guide. Not at all claiming expertise in this domain, but I used this approach on a couple of Linux Mint machines with the result of both happily displaying the default Rails site at http://railsweb.
Much of this will be repetitious from other reference sources, particularly Digital Ocean’s excellent How to Install Ruby on Rails on Ubuntu 12.04 LTS with RVM. There are some good comments to that guide as well. Here is a helpful RubyOnRails guide on Ubuntu's wiki which you may find useful.
We’ll start using the Digital Ocean approach to installing Ruby with the Ruby Version Manager. Then we will move on to configuring our Apache server with the goal of creating a Ruby on Rails site at the local address of http://railsweb.
We’re going to
- Install Ruby
- Install Rails
- Create a Rails Application at /home/daveburke/Projects/RailsWeb
- Configure Apache with Passenger to handle our site
We being by installing curl (if we don’t have it).
apt-get install curl
With curl installed retrieve and load ruby version manager.
\curl -l https://get.rvm.io | bash
Making sure we have all rvm dependencies installed with
which displays several dependency install options. This was the one for Ubuntu/Linux Mint 14.
apt-get --no-install-recommends install build-essential openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev libgdbm-dev ncurses-dev automake libtool bison subversion pkg-config libffi-dev
Now we’re ready to install Ruby with the Ruby Version Manager.
rvm install 1.9.3
rvm use 1.9.3 -- default
RubyGems are required components of Ruby on Rails.
rvm rubygems current
Though not specifically listed anywhere, from my reading I wanted to make nodejs was installed before creating the Rails Apache site
apt-get install nodejs
Simple enough to type, but it will take a bit to process.
gem install rails
Create Our First Rails Application
The following commands will create our first rails application to confirm that we're up and running on Rails before adding apache support.
rails new path/to/your/new/application
In our example we're creating a site in a User directory so we want to CHGRP of the Rails folder (/home/daveburke/Projects/RailsWeb) to www-data and CHMOD to 755.
Configuring Apache for http://railsweb site
We're going to install Passenger with Apache to support our Ruby applications. (It is assumed we added "railsweb" to our /etc/hosts file.)
gem install passenger
apt-get install apache2-dev libapr1-dev libaprutil1-dev
Because we're creating a virtual site at http://railsweb we'll add a file in /etc/apache2/sites-available for the site called "railsweb." Here's what that file looks like. Notice we're pointing to RailsWeb/public as the site root.
# !!! Be sure to point DocumentRoot to 'public'!
# This relaxes Apache security settings.
# MultiViews must be turned off.
Next we'll add two files in /etc/apache2/mods-available for passenger's load and conf.
LoadModule passenger_module /var/lib/gems/1.9.1/gems/passenger-3.0.19/ext/apache2/mod_passenger.so
Reload and Fire
Okay, that should do it. We're going to enable the Apache userdir and passenger modules and our railsweb site.
service apache2 restart
Our Welcome to Ruby on Rails page at http://railsweb.