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: 72% [?]



About
Mmm, Del.icio.us
Is there a particular reason that you compile Apache from source? Is the version in the repositories deficient in some regard?
yes, 2.0 is the version of apache that ubuntu's repositories feed you after an apt-get install apache.
Also, we need to to add mod_proxy_balancer support. Although, I suspect since one of the big features of 2.2 was mod_proxy_balancer, that when 2.2 is in the repositories, it will be compiled into it by default.
I want to have more control of installing apache2.2 from source. This is always a problem since you have to install from source other packages that depends on apache. Let's say I want PHP5. I just can't install the repository ones and I have to install it from source as well. This increases the aggravation of updating apache2.2, managing the source files (e.g. config files, directory locations, etc.), and reconfiguring the whole thing once 2.2 becomes available in the repositories. I tried using a source package manager like encap, but apache's custom directory locations break the /usr/local ones imposed by encap.
Hey Im using mod_proxy_balancer and mongrel_cluster... one issue I have is that when you restart the cluster, mod_proxy_balancer marks all the nodes as bad (Err), as they are temporarily not responding...
The only way I've found to fix that so far is to do an apache restart... graceful and reload don't work either... which is somewhat annoying...
Any ideas on how else to "unmark" the nodes as Err? Even disabling and enablign them in the proxy manager web ui doesn't work...
Two things:
First, why compile zlib? dapper has zlib 1.2.3
Second, you don't need to create the symlinks if you just install the ruby irb ir rdoc packages, since those packages will create the symlinks for you.
When I do apt-get on the various ruby modules I get errors on some of the packages, any reason why? Do I need to use a different source? If so, which one?
$ sudo apt-get install ri1.8
Reading package lists... Done
Building dependency tree... Done
Package ri1.8 is not available, but is referred to by another package. This may mean that the package is missing, has been obsoleted, or is only available from another source
E: Package ri1.8 has no installation candidate
$ sudo apt-get install rdoc1.8
Reading package lists... Done
Building dependency tree... Done
Package rdoc1.8 is not available, but is referred to by another package. This may mean that the package is missing, has been obsoleted, or is only available from another source
E: Package rdoc1.8 has no installation candidate
$ sudo apt-get install irb1.8
Reading package lists... Done
Building dependency tree... Done
E: Couldn't find package irb1.8
$ sudo apt-get install 1ibreadline-ruby1.8
Reading package lists... Done
Building dependency tree... Done
E: Couldn't find package 1ibreadline-ruby1.8
$ sudo apt-get install libreadline-ruby1.8
Reading package lists... Done
Building dependency tree... Done
E: Couldn't find package libreadline-ruby1.8
the packages do create symlink to ruby, irb etc. run whereis.
the problem for me is they aren't where you probably want them. I followed hivelogic guide to rails on mac os x and ruby is installed at /usr/local/bin/ruby so by making the link there you won't have to change the shebang in your apps.
Installing zlib from source isn't necessary, if you search the repositories for zlib-dev or similar, that should do the trick.
Also, if you want to compile with mod_ssl, just install the libssl-dev package.
Installing Apache 2.2.3 from source didn't work on my system. I think it might have to do with the old version not being properly removed.
The following packages will be REMOVED:
apache2
[...]
After unpacking 81.9kB disk space will be freed.
I don't think the Apache web server is a mere 82k in size. Seems to me, I have to remove other apache2 packages, too. Like apache2-common, apr, etc.
Anyway, after 'make install' arent the current files supposed to be overwritten with the 2.2.3 ones? This doesn't seem to be the case since after restarting Apache it is definetely the old version.
If somebody could please enlighten me.
BTW, why doesn't anybody bother to provide a 2.2 package for ubuntu? Installing from source isn't good practice when using a package management system.
And Nick is right: no need to install zlib from source.
Andreas, I know exactly what you mean. I had some problems both with the "cleansing" and the reinstall.
Jon, oftentimes just doing a "dpkg --purge apache apache2" won't remove all your apache related packages (usually you have at least apache2-common and other apache libs). You should use "dpkg -l apache2 | grep ^ii" to see all your old apache2 references, and then remove those packages.
Also, with the ./configure flags above, you're forcing apache2 to be installed into /usr/local/apache2. This is fine for a lot of people, but will be confusing for Ubuntu users, who are used to the /etc/apache2 setup. The Debian style /etc/apache2 with sites- and mods- is great, but it's non-standard for apache. First of all, your shiny new installation will completely ignore any existing /etc/apache2 structure and get everything from /usr/local/apache2. So Andreas, you didn't actually clear out all your old Apache2 stuff, and your new Apache2 stuff was partially written to a completely different folder structure, which would give you 2 versions (though not complete) of Apache to deal with.
From what I gather, to get the compilation to work the way you want it to, you'll have to tweak your ./configure statment. I don't know all the flags that you need to pass it (I'm just trying to go through the docs to find all this out), but you'll at least need to add: "--enable-layout=Debian"
to install to the standard Debian-style Apache folders (look at the config.layout file in your apache source files to get a feel for it). Your compiled httpd daemon also looks for the "httpd.conf" file by default, so you'll need to tell it at compile time that SERVER_CONFIG_FILE=/etc/apache2/apache2.conf.
If you already compiled httpd, you can see what it's exptecting by running "httpd -V" to see what the compile settings were.
Pretty damn confusing overall.
Anyone know all the right flags to pass during ./configure to get Apache to install in typical Ubuntu fashion? Or is there a pre-canned configure script we can use to make this easier? There is probably a much easier way to do this that I'm totally missing here. I think I'm just going to let it install into /usr/local/apache2 and try to be happy with the old config setup.
Here is the output of 'apache2 -V' on my Ubuntu 6.10 server. I hope this help anyone.
Server version: Apache/2.0.55
Server built: Sep 27 2006 16:52:14
Server's Module Magic Number: 20020903:11
Architecture: 32-bit
Server compiled with....
-D APACHE_MPM_DIR="server/mpm/prefork"
-D APR_HAS_SENDFILE
-D APR_HAS_MMAP
-D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
-D APR_USE_SYSVSEM_SERIALIZE
-D APR_USE_PTHREAD_SERIALIZE
-D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
-D APR_HAS_OTHER_CHILD
-D AP_HAVE_RELIABLE_PIPED_LOGS
-D HTTPD_ROOT=""
-D SUEXEC_BIN="/usr/lib/apache2/suexec2"
-D DEFAULT_PIDLOG="/var/run/apache2.pid"
-D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
-D DEFAULT_LOCKFILE="/var/run/apache2/accept.lock"
-D DEFAULT_ERRORLOG="logs/error_log"
-D AP_TYPES_CONFIG_FILE="/etc/apache2/mime.types"
-D SERVER_CONFIG_FILE="/etc/apache2/apache2.conf"
Hi, I was just wondering how to deploy into this environment, and if you had a good source for installing subversion into this environment. I am a newbie, but I want my first app up and running, cos' it's frustrating not being able to show my work to anyone. I am on a Windows XP development machine if that changes anything.
Any help you can offer would be muchly appreciated.
Thanks,
Paul.
Always use aptitude instead of apt-get so you can remove dependent packages easily.
The version of apache which is available from http://apache.rmplc.co.uk is now '2.2.3'.
For Apache2.2 Ubuntu dapper packages see : http://www.kodefoo.com/2007/2/18/deploying-rails-on-ubuntu-dapper
How to remove apache2.0.55?
I installed apache2.0.55 before I read this article. Following this
article, I installed apache2.2.3 without removing apache2.0.55. Now apache2.2.3 won't start -- I was informed that the address had been taken. I used sudo apt-install remove apache2 to remove apache2.0.55, but it said apache2 wasn't found on the system... what is wrong?
Apache is updated again... gotta get it with 2.2.4 now
Very helpful. If you want to be supernice for those copypasting at home you should include a cd subdir after the tar expansions for xlib and apache above - for the configure and make steps to work for the really trigger happy
Thanks for the great tutorial! Are there easy instructions to enable/build SSL (certificates, etc) for the apache/rails combo?
Thanks!
muy bueno el instructivo. gracias
[...] RailsConf, I've come to a satisfying decision of Apache 2.2, mod_proxy_balancer, and Mongrel. My next task was to get this stack working with multiple Rails apps in a shared environment. [...]
[...] Apache 2.2, mod_proxy_balancer, & Mongrel on Ubuntu 6.06 - If I had remembered this article yesterday, I could have avoided having to reinstall Apache today. Just remember to check the Apache site and pick your closest mirror for the download. [...]