Setting up a new machine for some pairs programming today gave me the ideal opportunity to look at what’s required now for a barebones installation of Ruby & Rails for Ubuntu
[UPDATED 2009-06-29: Switched from local mongrel to passenger)]
Get Ruby AND RUBYGEMS from apt-get (I’ve always previously compliled rubygems from source on Ubuntu)
sudo apt-get install ruby libopenssl-ruby libruby1.8 libreadline-ruby1.8 ruby1.8-dev build-essential
Get Rubygems – the latest from rubyforge.
wget http://rubyforge.org/frs/download.php/57643/rubygems-1.3.4.tgz
tar -xvzf rubygems-1.3.4.tgz
(tar output)
cd rubygems-1.3.4
ruby setup.rb
I’m now using Passenger in production – let’s get that and Rails
sudo apt-get install apache2-mpm-prefork apache2-mpm-prefork-dev
sudo gem install rails rake passenger
Then the installer for apache2
sudo passenger-install-apache2-module
Follow the Passenger installation instructions. I’ve put the config settings in the recommended location (/etc/apache2/conf.d/passenger)
LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger-2.2.4/ext/apache2/mod_passenger.so
PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-2.2.4
PassengerRuby /usr/bin/ruby1.8
I’m assuming that you know how to configure Apache virtual hosts. Here’s a summary of what I’ve done:
- Add an entry in /etc/hosts for each local site
- Add a virtualhost for each site… something like:
<VirtualHost *:80>
ServerName mysite
DocumentRoot /home/me/git/mysite/public
</VirtualHost>
If that wasn’t the path to an actual rails site… put one there
cd /home/me/git/
rails mysite
Check we’re up and running – fire up a browser and go to http://mysite Working? Great!
firefox mysite
Now to get a database running. Here’s the ‘real’ database (postgres)
sudo apt-get install postgresql-8.3 postgresql-client-8.3
sudo apt-get install libpq-dev
sudo gem install pg
…and for sqlite
sudo apt-get install libsqlite3-dev
sudo gem install sqlite3-ruby
If if you’ve got an existing site… there’ll be a bunch of required gems – use the rake task to grab ’em
sudo rake gems:install
After that… it’s time to get cracking with some Rails dev!