Fwd: Kubuntu, Apache 2.2, Mongrel, Mongrel Cluster

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> [email protected]
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
BalancerMember 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…

good work…

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…

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

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

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.

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 [email protected] 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


Posted via http://www.ruby-forum.com/.


Charles Brian Q.
self-promotion: www.seebq.com
highgroove studios: www.highgroove.com
slingshot hosting: www.slingshothosting.com

On 7/24/06, Andrew S. [email protected] 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