A fusion of technology, music, and geekyness.
Currently Browsing: SysAdmin

Integrating Ruby On Rails with Apache2 in Ubuntu 9.10

This is a quick and dirty walkthrough on how to integrate Rails with Apache2 in Ubuntu via Phusion Passenger. This guide provides setup instructions for a solution that includes:

  • Apache2
  • MySQL 5
  • Phusion Passenger
  • Ruby 1.8.7
  • RubyGems + gems

Install All Required Packages from Apt

sudo apt-get install apache2 ruby irb ruby1.8-dev rdoc build-essential libopenssl-ruby apache2-prefork-dev libapr1-dev libaprutil1-dev mysql-server libmysql-ruby libmysqlclient-dev

Install RubyGems

wget http://production.cf.rubygems.org/rubygems/rubygems-1.3.6.tgz
tar xvzf rubygems-1.3.6.tgz
cd rubygems-1.3.6.tgz
sudo ruby setup.rb
sudo ln -s /usr/bin/gem1.8 /usr/bin/gem

Install Required Gems

sudo gem install rails passenger mysql

Compile Passenger Apache2 Module

sudo /usr/bin/passenger-install-apache2-module

Configure Apache2

sudo vim /etc/apache2/mods-enabled/phusion.load

Add the following:

LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger-2.2.11/ext/apache2/mod_passenger.so
PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-2.2.11
PassengerRuby /usr/bin/ruby1.8
RailsEnv development

Setup Test Virtual Host

sudo rm /etc/apache2/sites-enabled/000-default
sudo vim /etc/apache2/sites-enabled/railstest

Add the following:

<VirtualHost *:80>
    ServerName localhost
    DocumentRoot /var/www/testapp/public
</VirtualHost>

Restart Apache2

sudo /etc/init.d/apache2 restart

Setup Default MySQL Database

mysqladmin create testapp_development -u root -p

Setup Test Rails Application

cd /var/www
sudo rm index.html
rails testapp -d mysql
cd testapp
sudo vim config/database.yml

Put in your root MySQL username and password.

Test!

  1. Open browser: http://localhost
  2. Click link: About your application’s environment

If you see something like the following then you were successful!

rails_welcome


Next Entries »

Powered by Wordpress | Designed by Elegant Themes