Tuesday, October 19, 2010

mod_jk instalation on ubuntu 9.4

Assuming Tomcat and Apache are installed and running

1. Install the mod_jk
sudo su -
apt-get install libapache2-mod-jk

2. Enable md_jk loading
cd /etc/apache2/mods-enabled
ln -s jk.load ../mods-available/jk.load

3. Create the mod_jk conf file
cd /etc/apache2/mods-available
vi jk.conf
# Where to find workers.properties
# Update this path to match your conf directory location
JkWorkersFile /etc/libapache2-mod-jk/workers.properties

# Where to put jk logs
# Update this path to match your logs directory location
JkLogFile /var/log/apache2/mod_jk.log

# Set the jk log level [debug/error/info]
JkLogLevel info

# Select the log format
JkLogStampFormat "[%a %b %d %H:%M:%S %Y]"

# JkOptions indicate to send SSL KEY SIZE,
JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories

# JkRequestLogFormat set the request format
JkRequestLogFormat "%w %V %T"

# Shm log file
JkShmFile /var/log/apache2/jk-runtime-status

4.Enable mod_jk configurations
cd ../mods-enabled
ln -s jk.conf ../mods-available/jk.conf

5. Create a worker properties file
vi /etc/libapache2-mod-jk/workers.properties
workers.tomcat_home=/var/lib/tomcat6
workers.java_home=/usr/lib/jvm/java-6-sun
ps=/
worker.ajp13_worker.port=8009
worker.ajp13_worker.host=localhost
worker.ajp13_worker.type=ajp13
worker.ajp13_worker.lbfactor=1

6.Configure url forwarding from Apache to Tomcat
cd /etc/apache2/sites-enabled
vi 000-default ##Which is a symbolic link to ../sites-available/default

...
JkMount /examples/ ajp13_worker
JkMount /examples/* ajp13_worker
JkMount /docs/ ajp13_worker
JkMount /docs/* ajp13_worker
...

##This will forward any request to /examples/ and /docs/ to Tomcat

7. Configure AJP in Tomcat Server.
vi /etc/tomcat6/server.xml
##Uncomment the following line


8. Restart Apache and Tomcat
/etc/init.d/tomcat6 restart
/etc/init.d/apache2 restart

9. Test it
Open a browser
http://localhost:8080/examples
Then remove the port
http://localhost:/examples

You must see the same content, so Apache is forwawrding the request to Tomcat to show /examples content

No comments:

Post a Comment