It’s been some time since I had to personally setup a web server and I needed a refresher on the numerous steps involved.
I wasn’t able to find all the documentation I needed in one place, but I did find various pieces here and there via Google. Based off of the items I came across and a few trial and error attempts at a few things, I was able to get things up and running. Here’s the compilation of the notes I took stepping through the basic process for setting up a web server to run a Ruby on Rails applications using Passenger (mod-rails).
—————————————————————————————————-
Starting out with the base install of Ubuntu server, log in as the root user.
Create a new user (use of the root user account should limited to bare essentials):
(Lines with a $ reference a command line entry)
$ useradd <name of new user>
Add the created user to the list of users with sudo rights:
$ visudo
Login as the user account you previously created
Install essential packages needed:
$ sudo apt-get install build-essential
$ sudo apt-get install vim
$ sudo apt-get install apache2
$ sudo apt-get install wget
$ sudo apt-get install libreadline5-dev
$ sudo apt-get install mysql-server
$ sudo apt-get install apache2-prefork-dev
$ sudo apt-get install libapr1-dev
Install ruby-ee:
$ sudo wget http://rubyforge.org/frs/download.php/55510/ruby-enterprise_1.8.6-20090421_i386.deb
$ sudo dpkg -i ruby-enterprise_1.8.6-20090421_i386.deb
Append the user shell path with /opt/ruby-enterprise/bin/
Install Passenger (mod-rails)
$sudo /opt/ruby-enterprise/bin/passenger-install-apache2-module
Add the following line to /etc/apache2/mods-available/passenger.load (Note that the passenger version may be different for you depending on the latest build)
LoadModule passenger_module /opt/ruby-enterprise/lib/ruby/gems/1.8/gems/passenger-2.2.3/ext/apache2/mod_passenger.so
Add the following line to /etc/apache2/mods-available/passenger.conf
PassengerRoot /opt/ruby-enterprise/lib/ruby/gems/1.8/gems/passenger-2.2.3
PassengerRuby /opt/ruby-enterprise/bin/ruby
Create symlinks to the above passenger files in /etc/apache2/mods-enabled
$ sudo ln -s /etc/apache2/mods-available/passenger.conf .
$ sudo ln -s /etc/apache2/mods-available/passenger.load .
Update the apache2.conf located in /etc/apache2 to point to the public folder of your rails app
<VirtualHost *:80>
ServerName yourhost.com
ServerAlias www.yourhost.com
DocumentRoot /somewhere/public # <— be sure to point to public!
</VirtualHost>
Restart Apache
sudo /etc/init.d/apache2 restart
And that’s it! Those are the bare basics to getting things up and running.
As a continuation of this, I recommend checking out the Passenger Users Guide for security and optimization tips and other useful information.