[Update: 04-20-2009]: There is now a version for Ubuntu Jaunty.
Step 1: As usual, the first thing we'll want to do is make sure your version of Intrepid Ibex 8.10 is up to date.:
sudo apt-get update
sudo apt-get dist-upgrade
Step 2: We'll be installing some software that needs to be built so we'll need to get packages required for compiling. In one swoop, you can type this command and get everything you need:
sudo apt-get install build-essential
Step 3: Once you've got the tools, it's time to install MySQL and Ruby. Just copy and paste this command into your terminal if you're in a hurry.
sudo apt-get install ruby ri rdoc mysql-server libmysql-ruby ruby1.8-dev irb1.8 libdbd-mysql-perl libdbi-perl libmysql-ruby1.8 libmysqlclient15off libnet-daemon-perl libplrpc-perl libreadline-ruby1.8 libruby1.8 mysql-client-5.0 mysql-common mysql-server-5.0 rdoc1.8 ri1.8 ruby1.8 irb libopenssl-ruby libopenssl-ruby1.8 libterm-readkey-perl psmisc
If you hadn't previously installed MySQL you'll be asked to set a root password. Don't forget what you choose!
Step 4: Grab the latest ruby gems and install them. As always be sure to check rubyforge.org to make sure you're grabbing the latest one. As of this writing it's 1.3.1 but it never hurts to confirm.
tar xvzf rubygems-1.3.1.tgz
sudo ruby setup.rb
Once it's done you can remove the .tgz file and erase the rubygems-1.3.1 directory too.
Step 5: Make symlinks. Just in case the symlinks did not get created for you (the symlink for gem was missing for me so don't assume) go ahead and create them with these commands:
sudo ln -s /usr/bin/gem1.8 /usr/local/bin/gem
sudo ln -s /usr/bin/ruby1.8 /usr/local/bin/ruby
sudo ln -s /usr/bin/rdoc1.8 /usr/local/bin/rdoc
sudo ln -s /usr/bin/ri1.8 /usr/local/bin/ri
sudo ln -s /usr/bin/irb1.8 /usr/local/bin/irb
Step 6: Install Ruby on Rails! You can leave off the --no-rdoc and --no-ri switches if you're on a machine with plenty of ram. But just in case you've got a more modest setup (say 256MB or less) I'd just use the following:
sudo gem install rails --no-rdoc --no-ri
If you're just doing local development then congratulations you are done! If you want to deploy Ruby on Rails onto a server then it's time to grab Apache and Phusion.
Step 7: If you're still reading then it means you are going to put this sucker on a server for the whole world to see. The first thing you'll need is to install Apache:
sudo apt-get install apache2 apache2-mpm-worker apache2-prefork-dev apache2-utils apache2.2-common comerr-dev libapr1 libapr1-dev libaprutil1 libaprutil1-dev libdb4.6-dev libexpat1-dev libkadm55 libkrb5-dev libldap2-dev libmysqlclient15-dev libpcre3-dev libpcrecpp0 libpq-dev libpq5 libsqlite3-dev libssl-dev openssl-blacklist ssl-cert uuid-dev zlib1g-dev apache2-utils apache2.2-common comerr-dev libapr1 libapr1-dev libaprutil1 libaprutil1-dev libdb4.6-dev libexpat1-dev libkadm55 libkrb5-dev libldap2-dev libmysqlclient15-dev libpcre3-dev libpcrecpp0 libpq-dev libpq5 libsqlite3-dev libssl-dev openssl-blacklist ssl-cert uuid-dev zlib1g-dev
That's a lot of files compared to what we might see with a lighter webserver. Phusion makes it worth it though so let's just keep going. If you are prompted to install other packages after entering the above command just say Yes.
Step 8: We're going to create a directory for your application. In anticipation of Capistrano, let's put it in /var/www/myapp/current. Swap out the myapp with anything you like.
sudo mkdir -p /var/www/myapp/current
Once you've got the directory setup, go ahead and copy your Rails application there. You should also chown it for www-data for the moment.
sudo chown -R www-data:www-data /var/www/myapp/current/
Now that Apache is set up, let's install Phusion Passenger:
sudo gem install passenger
Edit your Apache configuration file, and add these lines to the bottom:
LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger-2.0.3/ext/apache2/mod_passenger.so
Step 10: Now it's time to create your apache config and enable your site. There are plenty of examples on how to configure Apache out there. Create a file in your /etc/apache2/sites-available/ directory.. in our example we'll call it mywebsite, and populate it as required. You can also download this sample file if you want it.
Once that's done, it's time to enable the site in Apache and restart the webserver
sudo a2ensite-enable mywebsite
sudo /etc/init.d/apache2 restart
In case it's not already installed, let's grab the perquisites and then install the mysql gem. This will improve performance on your webserver:
sudo apt-get install libmysqlclient-dev
sudo gem install mysql --no-rdoc --no-ri
That's all there is! I always seem to miss some minor detail so feel free to leave a comment and I'll do my best to address any mistakes. For tech support I strongly encourage you to use the Ubuntu Forums!
For Ubuntu Hardy Heron (the current LTS release) see this link.