1f42 axeorcat: Moving to apache2 and mod_jk the debian way
Go to content Go to navigation Go to search

Moving to apache2 and mod_jk the debian way

Switched from doing manual tarball download, pgp/md5 verify and compiles to a packaged format as I dont have time any more. Debian breaks the apache2 config down into chunks. It's a bit clunky but I have to live with it. The advantages of managed packages are what I'm after.

To keep it simple I only made minor changes to apache2.conf.
* I added index.jsp to the index file list
* I enabled server-info and server-status
* I changed the error log file location
I put nothing in httpd.conf.
I created new config files for my own site setup in conf.d.
I needed to do a lot of "chgrp www-data"ing to get everything working and put my tomcat user in the www-data group. Tomcat very annoyingly deletes its deployment descriptors if it cant read the appbase directory giving you just the default webapp back again. I chmod'ed it this time so it can't delete it.

mod_jk2 is deprecated (good, it was a pile of crap and I've been using mod_jk with apache2 in production for years anyway). There's no mod_jk debian package for apache2 though at the moment for some reason so I stuck to the manual option for that.


* aptitude install apache2-dev libapache2-mod-php4 php4-pear php4-curl php4-dev php4-domxml php4-gd php4-imap php4-ldap php4-mcal php4-mhash php4-mysql php4-pgsql php4-odbc php4-pear php4-xslt curl libwww-perl imagemagick
# setup your files in conf.d e.g.
0.common.conf 1.jk.conf 2.vhosts.conf



* wget http://www.apache.org/dist/tomcat/
tomcat-connectors/jk/source/jk-1.2.15/jakarta-tomcat-connectors-1.2.15-src.tar.gz
* tar zxf jakarta-tomcat-connectors-1.2.15-src.tar.gz
* cd jk/native
* ./configure --with-apxs=/usr/bin/apxs2
* make; sudo make install


Configure jk ref

LoadModule jk_module /usr/lib/apache2/modules/mod_jk.so

JkWorkersFile /etc/apache2/workers.properties
JkLogFile /var/www/logs/mod_jk.log
JkLogLevel error
JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories
JkRequestLogFormat "%w %V %T"

# we never want jk to serve php,pl or static resources
SetEnvIfNoCase Request_URI "\.(txt|ico|html|htm|gif|png|jpg|css|php|pl|js|mp3|swf)$" no-jk


To stop URLs going to JK you can:
* JkUnmount /foo* worker1
* SetEnvIfNoCase Request_URI /webstats no-jk
* SetEnvIfNoCase Server_Addr 192.168.1.1 no-jk
etc

NB if you use JkUnMount in a vhost you must also use JkMount to mount everything else at the vhost level.

At global scope map everything to java: JkMount /* worker1
At vhost scope disable non-java vhosts: SetEnv no-jk 1


# workers.properties file - I havent tuned this yet
# Define 1 real worker using ajp13
worker.list=worker1
# Set properties for worker1 (ajp13)
worker.worker1.type=ajp13
worker.worker1.host=localhost
worker.worker1.port=2013
worker.worker1.lbfactor=50
worker.worker1.cachesize=10
worker.worker1.cache_timeout=600
worker.worker1.socket_keepalive=1
worker.worker1.socket_timeout=300
Previous post:
Wierd apt behaviour when downgrading
Next post:
Tomcat JSP Strangeness

0