Ubuntu 12.10 Quantal Quetzal Ruby on Rails Server Configuration

note from Wed Jan 23, 2013

Here are the notes for configuring my Ubuntu 12.10 installations for Ruby on Rails + MySql + Passenger + Apache. It is a base installation plus a few other things that I find always necessary for my projects. This was current as of the date the notes were made, so version numbers of things like rubygems might be different now, but I kept the notes as-is because these were known the compatible versions at that time. There are some additional notes in the comments, and variations for some installations that had specifiec requirements (like Rails 2.x).

# update apt-get list
sudo apt-get update

# all packages at once, will still have to enter mysql root pw
sudo apt-get install emacs23-nox ruby ri rdoc irb ruby-dev apache2.2-common apache2-mpm-prefork apache2-prefork-dev apache2-utils libapr1-dev mysql-common mysql-server mysql-client libmysql-ruby libmysqlclient15-dev build-essential manpages-dev git-core libopenssl-ruby imagemagick libmagickcore-dev libmagickwand-dev libxml2 libxml2-dev libxslt1.1 libxslt1-dev libcurl4-gnutls-dev -y

# rubygems
wget http://production.cf.rubygems.org/rubygems/rubygems-1.8.24.tgz; tar zxvf rubygems-1.8.24.tgz; cd rubygems-1.8.24; sudo ruby setup.rb; cd ..; sudo gem update --system
# ruby 1.9 should have /usr/bin/gem -> /etc/alternatives/gem
# which should already be /usr/bin/gem1.9.1

# for rails 2: gems (install rails separately if specific version is needed)
# sudo gem install rails -v 2.3.5; sudo gem install mysql passenger rmagick aws-s3 will_paginate

# rails 3: use bundler
sudo gem install bundler
sudo gem install rake

# rails 3 asset pipe requires a supported JS engine
sudo gem install therubyracer

# deploy, then
sudo bundle install

# passenger
sudo gem install passenger

# passenger apache module
sudo passenger-install-apache2-module

# capture the output from above and add to apache.conf
# it should look something like this:
#
# LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger-3.0.15/ext/apache2/mod_passenger.so
# PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-3.0.15
# PassengerRuby /usr/bin/ruby1.8

# add virtual host block similar to the one below to a file in /etc/apache2/sites-available named something like mysite.conf
# <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>

# config apache
# enable sites
sudo a2ensite mysite

# enable rewrite mod with a2enmod rewrite
sudo a2enmod rewrite

# install postfix if necessary
# remember to change smtpd_use_tls=no in /etc/postfix/main.cf
sudo apt-get install postfix
tags: #linux #ubuntu #server #config #passenger #apache

What I'm reading now

A friend recommended "The Little Schemer." The book sets out to teach good recursive thinking through the Scheme programming language. It's slow reading for me, but I am quite enjoying it. I'm learning quite a lot from it. Here's a link to it on Amazon where you can read more about it.

Rails books

This is the grandaddy of the Ruby on Rails books. Most Rails developers I know (including myself) started with this one.

I also like the Rails Recipes book from the same publisher, as it gives real world problems that I can relate to and then sample solutions. There doesn't seem to be a Rails 4 edition yet. Here is the most recent one that I've found.