Apache 2.2, mod_proxy_balancer, & Mongrel on Ubuntu 6.06

Ok after playing with Ubuntu, Apache 2.2, mod_proxy_balancer, and Mongrel, I've decided that this is the deployment stack I want to use for at least the next month. snicker

Since I was using a few different sources as references while setting this up, I thought I'd post exactly what I did to get everything installed correctly to suit my needs. This won't go into how to actually DEPLOY your rails app into this environment, but it'll show you what you need to do to get it all installed and set up.

UPDATE: This works on Edgy (6.10) as well...

UPDATE 2: Some things updated for Apache 2.2.4

UPDATE 3: Now with Subversion hotness

Deployment Stack

  • Ubuntu Linux 6.06 Dapper Drake
  • Apache 2.2
  • mod_proxy_balancer
  • Mongrel

Sources

Everything below was taken directly (and sometimes even copied and pasted) from the sources above. They are the real heros here. I"m just the aggregator. I'm pretty sure the "one customer" mentioned in the rimuhosting post is Ezra as well. But I could be mistaken.
Ok, lets start.

Its assumed that you are su'd to root.

Core Essentials

Make sure you remove any version of apache that already exists!

sudo dpkg --purge apache apache2

Install the GCC compilers and developer tools.

sudo apt-get install build-essential

Now we'll install Ruby and friends:

sudo apt-get install ruby1.8-dev ruby1.8 ri1.8 rdoc1.8 irb1.8 libreadline-ruby1.8 libruby1.8

Next we need to make some symlinks for basic Ruby commands.


sudo ln -s /usr/bin/ruby1.8 /usr/local/bin/ruby
sudo ln -s /usr/bin/ri1.8 /usr/local/bin/ri
sudo ln -s /usr/bin/rdoc1.8 /usr/local/bin/rdoc
sudo ln -s /usr/bin/irb1.8 /usr/local/bin/irb

Apache & Pals

Download and compile Zlib


wget http://www.zlib.net/zlib-1.2.3.tar.gz
tar -xvf zlib-1.2.3.tar.gz
./configure
make
sudo make install

Download and compile Apache 2.2


wget http://apache.rmplc.co.uk/httpd/httpd-2.2.4.tar.gz
tar -xvf httpd-2.2.4.tar.gz
./configure --prefix=/usr/local/apache --enable-proxy   --enable-proxy-http   --enable-proxy-balancer --enable-dav --enable-rewrite    --enable-so --enable-http   --enable-ssl    --enable-expires  --enable-headers  --enable-mods=deflate_module --with-php --with-mysql --with-susexec --disable-info  --without-berkeley-db --enable-dav=shared --enable-dav-lock=shared --with-included-apr
make
sudo make install

MySQL & Postfix

Lets install Postfix here really quick. We will configure it later but if we don't install it before we install MySQL, apt will pull in Exim as a dependency. We don't want this so lets pre-empt it by installing Postfix.
sudo apt-get install postfix

The Postfix installer will ask you a question about what type of server it is. I just chose "Internet Site".

Now let's install MySQL and friends.
sudo apt-get install mysql-server mysql-common mysql-client libmysqlclient15-dev libmysqlclient15off

Install the MySQL bindings.
sudo apt-get install libmysql-ruby1.8

Now test it:


irb
irb(main):001:0> require 'mysql'
=> true
irb(main):002:0> exit

Now we will install RubyGems so we can get Rails and all kinds of other Ruby treasures!


wget http://rubyforge.iasi.roedu.net/files/rubygems/rubygems-0.9.0.tgz
tar xvzf rubygems*
cd rubygems*
sudo ruby setup.rb

Now we'll install the latest version of Rails.
sudo gem install rails --include-dependencies

You should see (as of Rails 1.2.3):


Successfully installed rails-1.2.3
Successfully installed rake-0.7.2
Successfully installed activesupport-1.4.2
Successfully installed activerecord-1.15.3
Successfully installed actionpack-1.13.3
Successfully installed actionmailer-1.3.3
Successfully installed actionwebservice-1.2.3
Installing ri documentation for rake-0.7.2...
Installing ri documentation for activesupport-1.4.2...
Installing ri documentation for activerecord-1.15.3...
Installing ri documentation for actionpack-1.13.3...

lib/action_controller/routing.rb:1061:30: ':' not followed by identified or operator

lib/action_controller/routing.rb:1065:39: ':' not followed by identified or operator
Installing ri documentation for actionmailer-1.3.3...
Installing ri documentation for actionwebservice-1.2.3...
Installing RDoc documentation for rake-0.7.2...
Installing RDoc documentation for activesupport-1.4.2...
Installing RDoc documentation for activerecord-1.15.3...
Installing RDoc documentation for actionpack-1.13.3...

lib/action_controller/routing.rb:1061:30: ':' not followed by identified or operator

lib/action_controller/routing.rb:1065:39: ':' not followed by identified or operator
Installing RDoc documentation for actionmailer-1.3.3...
Installing RDoc documentation for actionwebservice-1.2.3...

Don't worry about those couple of errors. That just happens sometimes when building the RDoc documentation. If you look closely, you will see that it says "Successfully installed foobar..." a bunch of times.

Mongrel & Friends

Install mongrel and its supporting software. Make sure when prompted you select the most recent, non mswin32 option.
sudo gem install daemons gem_plugin mongrel mongrel_cluster --include-dependencies

It was previously advised to install Sendfile in this stack, but apparently it doesn't serve the static content like it was once suggested. So the speed boost isn't actually there. This means its just extra software to blow up. So don't install it.

This comes strait from Coda, which came strait from Zed. And you listen to Zed.

Subversion

Ok, now lets throw subversion on the box. You might need to grab the libxml2 libs, so apt-get them first. Then download Subversion and compile it. You'll probably be warned that the Berkeley DB isn't installed. Just ignore it. I do.


sudo apt-get install libxml2-dev
wget http://subversion.tigris.org/downloads/subversion-1.3.2.tar.gz
tar xfz subversion-1.3.2.tar.gz
cd subversion-1.3.2
./configure --with-apr=/usr/local/apache/bin/apr-1-config --with-apr-util=/usr/local/apache/bin/apu-1-config --with-apxs=/usr/local/apache/bin/apxs --without-berkeley-db --with-ssl

Further Reading

Simply put, go read Coda's post on how to turn all the elements you just installed into a real working mongrel cluster.

I'm in the process of setting up a shared environment for my pre-production server. So I'll have this stack working for multiple sites on one computer using virtual hosts. I'll share the apache conf files when I've got them finalized.

Popularity: 40% [?]

    Categories: Deployment, Rails, Ruby     23 Comments »

First Mongrel Cluster Is Go

mongrel cluster

If you're looking to figure out how to get this going, check out those sites. Between all of them, you should be able to figure it out. Its pretty trivial really, it a very nice little deployment stack.

On a side note, I've only had Ubuntu on my server for about 2 evenings. This is my second night playing with it, and I'm very impressed. I haven't hit a single snag yet. Its the snags that always left a bad taste in my mouth about Linux. And I'm talking about using it as a desktop.

Linux has always been my server of choice, but desktop wise it stinks. Desktop linux has always felt like a hodgepodge of applications masquerading as a complete operating system. Ubuntu is far from that. It feels like one uniform operating system. I'm truly impressed.

NOTE: I'm not a developer for tv.com. I'm just a lazy programmer that typed a short url for testing.

Popularity: 4% [?]

    Categories: Deployment, Rails     1 Comment »