Ubuntu, Rails, Typo and Apache2
I know dapper is in pre-release right now, but I decided to go ahead and get flight2 up and running, and document my experience installing Typo from scratch.
This install basically requires 2 steps, only one of which I’m going to document. The first step, is installing Ubuntu Dapper Flight 2, and this is up to you. These instructions will almost certainly work with Breezy, and possibly some of the older versions of Ubuntu. As far as Debian is concerned, I have no idea whether or not this will work, so YMMV.
Ubuntu Repository Data
First and foremost, in order to have a working Rails install, we’re going to need to enable the universe repository.
Open /etc/apt/sources.list, and make sure to uncomment the lines for the universe repository.
Ruby
As rails is written in Ruby, you need to install a working ruby environment with all the bells and whistles!
sudo apt-get install ruby irb irb1.8 libdbm-ruby1.8 libfcgi-ruby1.8 libfcgi0 libgdbm-ruby1.8 libopenssl-ruby1.8 libruby1.8-dbg ri ri1.8 ruby1.8-dev
RubyGems
Because ubuntu doesn’t include rubygems in their repository, you have to install rubygems from source. Fortunately, this isn’t a very complicated installation method, and rubygems has a mechanism to insure it stays up to date outside of APT.
wget http://rubyforge.org/frs/download.php/5207/rubygems-0.8.11.tgz
tar zxvf rubygems-0.8.11.tgz
cd rubygems-0.8.11
sudo ruby1.8 setup.rb
As of this writing, Rubygems-0.8.11 was the most current version of rubygems, but you might want to make sure that rubygems is up to date with this command: sudo gem install rubygems-update
Installing Mysql
Typo doesn’t require MySQL, but that’s the database that I use to host my blog. To install MySQL, we simply:
sudo apt-get install mysql-common libmysqlclient12 libmysqlclient12-dev mysql-server libmysql-ruby1.8
I know that libmysql-ruby1.8 installs the mysql ruby bindings, but in order to make sure I have the most updated bindings, I run:
sudo gem install mysql -y
Installing Rails
sudo gem install rails -y
Installing Apache2 with fastcgi bindings
sudo apt-get install apache2 libapache2-mod-fcgid
sudo a2enmod fcgid
sudo a2enmod rewrite
sudo /etc/init.d/apache2 restart
Build Essential
Technically, the build-essential packages aren’t necessary, as there are fcgi libraries in Ubuntu, but I always install them anyway. You never know when you’re going to need this stuff
sudo apt-get install build-essential
At this point, rails should be installed and functioning.
FastCGI
There are two ways to go about installing FastCGI support, one through APT, the other directly from source.
apt-get install libfcgi-dev
sudo gem install fcgi
Other Modules
There are a number of useful gems that one can install, and installation is a snap with Rubygems.
Say for example you want to install the flickr interface. You’d simply type
sudo gem install flickr -y
and the gem is automagically installed.
Installing Typo
I’m installing typo from the SVN repository, as I find that the code isn’t too ‘bleeding edge,’ and staying current generally has more benefits than drawbacks. In order to check out the code, I went to the
/var/www/
directory, and typed
svn checkout svn://leetsoft.com/typo/trunk typo
Typo is now installed on the machine, but we first have to create the database, add the typo host, and then make some changes in order to ensure that the proper page is displayed.
Creating the typo database is a fairly simple procedure. Use mysqladmin to create the databases like this:
mysqladmin -u root -p create typo_dev
mysqladmin -u root -p create typo_tests
Optionally, you can create a separate database for production usage as well. Then import the database schema like so:
cd /var/www/typo/db
mysql -u root -p typo_dev < schema.mysql-v3.sql
Finally you need to edit the
config/database.yml
file. Mine is set up as follows:
login: &login
adapter: mysql
host: localhost
username: root
password: ROOT_PASSWORD
development:
database: typo_dev
<<: *login
test:
database: typo_tests
<<: *login
production:
database: typo_dev
<<: *login
I created my own vhost for typo. I created a file called
typo
in
/etc/apache2/sites-available
. For the contents of the file i included the following:
NameVirtualHost *
ServerName sethbc.org
DocumentRoot /var/www/typo/public/
ErrorLog /var/log/apache2/error.log
LogLevel warn
CustomLog /var/log/apache2/typo.log combined
Options ExecCGI FollowSymLinks
AddHandler cgi-script .cgi
AllowOverride all
Order allow,deny
Allow from all
After creating the vhost, make sure to restart apache with
sudo /etc/init.d/apache2 restart
.
The next step in the installation is modifying typo to work properly with the default Ubuntu fcgid handler. In order to do this, open the
.htaccess
file in the public directory of your typo installation, and change
AddHandler fastcgi-script .fcgi
to
AddHandler fcgid-script .fcgi
What else can you do?
I’m planning on writing another one of these, with the aim of getting lighttpd running on ubuntu. As of right now, there is a request for inclusion of lighttpd in Ubuntu, and I’m under the impression that it is now approved for debian, so that should speed the process up somewhat.
Resources
Ruby, Rails, Apache 2 and Ubuntu Breezy (5.10) – http://fo64.com/articles/2005/10/20/rails-on-breezy
RailsOnUbuntuDebianTestingAndUnstable – http://wiki.rubyonrails.com/rails/pages/RailsOnUbuntuDebianTestingAndUnstable
How to install Ruby on Rails on Ubuntu 5.10 – http://claudio.cicali.org/article/74/how-to-install-ruby-on-rails-on-ubuntu-510