# Fwd: Kubuntu, Apache 2.2, Mongrel, Mongrel Cluster

**URL:** <https://www.ruby-forum.com/t/fwd-kubuntu-apache-2-2-mongrel-mongrel-cluster/99548>\
**Category:** Rails\
**Created:** [July 24, 2006, 1:42am UTC](https://www.ruby-forum.com/t/fwd-kubuntu-apache-2-2-mongrel-mongrel-cluster/99548 "2006-07-24T01:42:20Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![starmaerker](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/e9bcb4/32.png) [@starmaerker](https://www.ruby-forum.com/u/starmaerker)\
**Post date:** [July 24, 2006, 1:42am UTC](https://www.ruby-forum.com/t/fwd-kubuntu-apache-2-2-mongrel-mongrel-cluster/99548/1 "2006-07-24T01:42:20Z")

</div>

Good suggestion, thanks. Also found a small error (lack of a cd  
command).  
The following is the entire notes:

# ~~~~~~~~~~~~~~~  
#Starting notes  
# ~~~~~~~~~~~~~~~

#get some necessary packages before beginning  
#some are used to build ruby, some are required  
#for gems that will be installed/built later  
sudo wajig install build-essential libssl-dev ssl-cert libssl0.9.8  
openssl  
slapd ldap-utils libldap2 imagemagick libmagick9 libmagick9-dev  
libldap2-dev  
memcached zlib1g zlib1g-dev

#dowload apache2.2 source and extract  
#in apache2.2 source dir  
#apache 2.2 configure  
./configure --prefix=/etc/apache2 --enable-cache --enable-mem-cache  
–enable-deflate --enable-proxy --enable-proxy-html  
–enable-proxy-balancer  
–enable-rewrite  
make  
sudo make install

#download Ruby source  
#edit ext/Setup to look like:  
# ~~~~~~~~~~~~~  
#begin ext/Setup  
# ~~~~~~~~~~~~~  
option nodynamic

#Win32API  
bigdecimal  
curses  
dbm  
digest  
digest/md5  
digest/rmd160  
digest/sha1  
digest/sha2  
#dl  
etc  
enumerator  
fcntl  
#gdbm  
iconv  
#io/wait  
nkf  
#pty  
openssl  
racc/cparse  
readline  
#sdbm  
socket  
stringio  
strscan  
syck  
syslog  
#tcltklib  
#tk  
#win32ole  
zlib  
# ~~~~~~~~~~~~~~~  
#end ext/Setup  
# ~~~~~~~~~~~~~~~

#in ruby source dir  
./configure  
make  
sudo make install

#dowload ruby gems source, tar -xvzf ruby-source  
#in ruby source dir  
ruby setup.rb  
#if you receive permission error on creating directories, manually  
create  
them

gem install rails --include-dependencies

gem install daemons gem\_plugin mongrel mongrel\_cluster sendfile  
–include-dependencies

gem install rmagick postgres-pr memcache-client vim-ruby pdf\_writer  
–include-dependencies

#In your rails app dir  
#create the config/mongrel\_cluster.yml  
#-e : environment (production, development (default))  
#-p : port  
#-a : address (using localhost)  
#-N : number of clients  
#-c : work dir (should be RAILS\_ROOT dir of application)  
mongrel\_rails cluster::configure -e development -p 8000 -a 127.0.0.1 -N  
2 -c  
/var/www/\<your\_app\>

#configure mongrel cluster as system service  
cd /etc/init.d  
sudo ln -s  
/usr/local/lib/ruby/gems/1.8/gems/mongrel\_cluster-0.2.0/resources/mongrel\_cluster  
mongrel\_cluster  
sudo chmod +x mongrel\_cluster  
sudo /usr/sbin/update-rc.d mongrel\_cluster defaults  
#fyi: to remove  
#sudo /usr/sbin/update-rc.d mongrel\_cluster remove

cd /etc  
sudo mkdir mongrel\_cluster  
cd mongrel\_cluster  
sudo ln -s /var/www//config/mongrel\_cluster.yml \<your\_app\>.yml

#apache configuration  
sudo cp httpd.conf httpd.conf.orig

sudo vi httpd.conf  
#change DocumentRoot defining htdocs  
#DocumentRoot “/var/www”  
#change Directory defining htdocs  
#Directory “/var/www”\>

#create a common configuration that applies to all apps  
sudo vi /etc/apache2/conf/common.conf  
# ~~~~~~~~~~~~~~~  
#begin common.conf  
# ~~~~~~~~~~~~~~~

UseCanonicalName Off  
ServerSignature On

\<Directory /var/www/\>  
Options FollowSymLinks  
Allow from all

# ~~~~~~~~~~~~~~~~~  
#end common.conf  
# ~~~~~~~~~~~~~~~~~

#vhost definition  
cd /etc/apache2/conf/extra  
sudo cp httpd-vhosts.conf httpd-vhosts.conf.orig  
sudo vi httpd-vhost.conf

# ~~~~~~~~~~~~~~~~~~  
#begin httpd-vhosts.conf  
# ~~~~~~~~~~~~~~~~~~  
NameVirtualHost \*:80  
\<VirtualHost \*:80\>  
ServerAdmin \<your\_email\> [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
ServerName \<your\_app\>.com  
DocumentRoot /var/www/\<your\_app\>/public  
ErrorLog /var/log/apache2/\<your\_app\>\_error\_log  
CustomLog /var/log/apache2/\<your\_app\>\_access\_log combined

\<Directory /var/www/\<your\_app\>/public\>  
Options FollowSymLinks  
AllowOverride None  
Order allow,deny  
Allow from all

ProxyPass /images !  
ProxyPass /stylesheets !  
ProxyPass /javascripts !  
ProxyPass /favicon.ico !  
ProxyPass / balancer://\<your\_app\>\_cluster  
ProxyPreserveHost On

\<Proxy balancer://\<your\_app\>\_cluster\>  
BalancerMember [http://127.0.0.1:8000](http://127.0.0.1:8000)  
BalancerMember [http://127.0.0.1:8001](http://127.0.0.1:8001)

RewriteEngine On

# Uncomment for rewrite debugging

#RewriteLog /var/log/apache2/\<your\_app\>\_rewrite\_log  
#RewriteLogLevel 9

# Rewrite index to check for static

RewriteRule ^/$ /index.html [QSA]

# Rewrite to check for Rails cached page

RewriteRule ^([^.]+)$ $1.html [QSA]

# Redirect all non-static requests to cluster

RewriteCond %{DOCUMENT\_ROOT}/%{REQUEST\_FILENAME} !-f  
RewriteRule ^/(.\*)$ balancer://\<your\_app\>\_cluster%{REQUEST\_URI}  
[P,QSA,L]

# Deflate

AddOutputFilterByType DEFLATE text/html text/plain text/xml  
application/xml application/xhtml+xml text/javascript text/css  
BrowserMatch ^Mozilla/4 gzip-only-text/html  
BrowserMatch ^Mozilla/4.0[678] no-gzip  
BrowserMatch bMSIE !no-gzip !gzip-only-text/html

# Uncomment for deflate debugging

#DeflateFilterNote Input input\_info  
#DeflateFilterNote Output output\_info  
#DeflateFilterNote Ratio ratio\_info  
#LogFormat ‘“%r” %{output\_info}n/%{input\_info}n (%{ratio\_info}n%%)’  
deflate  
#CustomLog /var/log/apache2/\<your\_app\>\_deflate\_log deflate

# ~~~~~~~~~~~  
#end httpd-vhosts.conf  
# ~~~~~~~~~~~

cd /etc/apache2/conf  
sudo vi httpd.conf  
#first line under Supplemental configuration  
#include your common.conf  
Includ conf/common.conf

#enable vhosts in /etc/apache2/conf/httpd.conf  
#uncomment the following  
Include conf/extra/httpd-vhosts.conf

#start/stop by using  
sudo /etc/apache2/bin/apachectl (start|stop)

# ~~~~~~~~~~~~~~~  
#ending notes  
# ~~~~~~~~~~~~~~~

I really hope this formats okay…

---

<div class="post-metadata">

**Author:** ![starmaerker](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/e9bcb4/32.png) [@starmaerker](https://www.ruby-forum.com/u/starmaerker)\
**Post date:** [August 5, 2006, 8:17am UTC](https://www.ruby-forum.com/t/fwd-kubuntu-apache-2-2-mongrel-mongrel-cluster/99548/2 "2006-08-05T08:17:49Z")

</div>

good work…

---

<div class="post-metadata">

**Author:** ![starmaerker](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/e9bcb4/32.png) [@starmaerker](https://www.ruby-forum.com/u/starmaerker)\
**Post date:** [August 5, 2006, 10:06am UTC](https://www.ruby-forum.com/t/fwd-kubuntu-apache-2-2-mongrel-mongrel-cluster/99548/3 "2006-08-05T10:06:58Z")

</div>

I think the rewrite rules will never be used here… I have run tests  
and it appears that cached contents are served by Mongrel instead of  
Apache with such a configuration. You should use either proxy pass  
exceptions (! rules), or rewrite. But I might be wrong…

Proxy pass exceptions are faster for everything that is in the excluded  
directories, but they just forward everything else to Mongrel, including  
cached content…

But once more, I can be totally wrong…

---

<div class="post-metadata">

**Author:** ![starmaerker](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/e9bcb4/32.png) [@starmaerker](https://www.ruby-forum.com/u/starmaerker)\
**Post date:** [October 30, 2006, 2:35pm UTC](https://www.ruby-forum.com/t/fwd-kubuntu-apache-2-2-mongrel-mongrel-cluster/99548/4 "2006-10-30T14:35:45Z")

</div>

My httpd.conf is almost the same as above,however my log shows that the  
mod\_deflate does not take into effect. I have mentioned this topic at :  
[http://www.ruby-forum.com/topic/86475](http://www.ruby-forum.com/topic/86475)

---

<div class="post-metadata">

**Author:** ![starmaerker](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/e9bcb4/32.png) [@starmaerker](https://www.ruby-forum.com/u/starmaerker)\
**Post date:** [October 31, 2006, 4:14pm UTC](https://www.ruby-forum.com/t/fwd-kubuntu-apache-2-2-mongrel-mongrel-cluster/99548/5 "2006-10-31T16:14:40Z")

</div>

ethan wrote:

> My httpd.conf is almost the same as above,however my log shows that the  
> mod\_deflate does not take into effect. I have mentioned this topic at :  
> [Apache2 mod\_deflate does not work - Rails - Ruby-Forum](http://www.ruby-forum.com/topic/86475)

I guess the original config as follows stop mod\_deflate from compressing  
the javascripts,stylesheets,etc for IE

BrowserMatch ^Mozilla/4 gzip-only-text/html  
BrowserMatch ^Mozilla/4.0[678] no-gzip  
BrowserMatch bMSIE !no-gzip !gzip-only-text/html

Therefore the above three sentences should be commented.

---

<div class="post-metadata">

**Author:** ![starmaerker](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/e9bcb4/32.png) [@starmaerker](https://www.ruby-forum.com/u/starmaerker)\
**Post date:** [November 7, 2006, 10:47am UTC](https://www.ruby-forum.com/t/fwd-kubuntu-apache-2-2-mongrel-mongrel-cluster/99548/6 "2006-11-07T10:47:09Z")

</div>

I think there is a typo, it has been corrected on several guides:

BrowserMatch bMSIE !no-gzip !gzip-only

should read:

BrowserMatch \bMSIE !no-gzip !gzip-only

Also, I’m hoping your line got truncated as I did on the mongrel  
apache2 guide here:

AddOutputFilterByType DEFLATE text/html text/plain text/xml  
application/xml application/xhtml+xml text/javascript text/css

That should all be one line.

On 10/30/06, ethan [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> My httpd.conf is almost the same as above,however my log shows that the  
> mod\_deflate does not take into effect. I have mentioned this topic at :  
> [Apache2 mod\_deflate does not work - Rails - Ruby-Forum](http://www.ruby-forum.com/topic/86475)
> 
> –  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).
> 
> >

–  
Charles Brian Q.  
self-promotion: [www.seebq.com](http://www.seebq.com)  
highgroove studios: [www.highgroove.com](http://www.highgroove.com)  
slingshot hosting: [www.slingshothosting.com](http://www.slingshothosting.com)

---

<div class="post-metadata">

**Author:** ![starmaerker](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/e9bcb4/32.png) [@starmaerker](https://www.ruby-forum.com/u/starmaerker)\
**Post date:** [November 12, 2006, 4:20pm UTC](https://www.ruby-forum.com/t/fwd-kubuntu-apache-2-2-mongrel-mongrel-cluster/99548/7 "2006-11-12T16:20:07Z")

</div>

On 7/24/06, Andrew S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> sudo vi httpd.conf  
> #change DocumentRoot defining htdocs  
> #DocumentRoot “/var/www”  
> #change Directory defining htdocs  
> #Directory “/var/www”\>  
> what do you mean by #Directory “/var/www”\> ? I don’t see anything like  
> that. Could you show me what the whole Directory thing look like?

Thanx in advance

Pat
