katratxo on Software Development

tail -f /var/log/brain | grep -i software

Configuring mod_jk in a development environment

with 2 comments

Some issues are only reproducible in production environments, that’s why a development environment must be as much as possible like the production one.

A well configured production environment should use Apache web server ‘in front‘ of  Tomcat, so all requests/responses made to/from Tomcat are handled by the web server through the Tomcat redirector module (mod_jk). This is a quick how-to configure this module.

Gentoo

  • Install Apache web server and the mod_jk module:
emerge -av www-servers/apache www-apache/mod_jk
  • Edit the /etc/conf.d/apache2 and add -D JK to the APACHE2_OPTS variable
APACHE2_OPTS="-D DEFAULT_VHOST -D INFO -D LANGUAGE -D SSL -D SSL_DEFAULT_VHOST -D JK"
  • Create a /etc/apache2/modules.d/88_mod_jk.conf file with the following content:

LoadModule jk_module    modules/mod_jk.so
JkWorkersFile	/etc/apache2/jk-workers.properties
JkLogFile	/var/log/apache2/mod_jk.log
JkShmFile	/var/log/apache2/mod_jk.shm
JkLogLevel	warn
JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories
JkRequestLogFormat "%w %V %T"
JkMount /openbravo* ajp13
JkMountCopy all

  • Create the workers file /etc/apache2/jk-workers.properties with the following content:
# workers.properties -
worker.list=ajp13
worker.ajp13.port=8009
worker.ajp13.host=localhost
worker.ajp13.type=ajp13
worker.ajp13.lbfactor=1
  • Restart apache web server
/etc/init.d/apache2 restart

Ubuntu

  • Install Apache web server and mod_jk module
sudo apt-get install apache2 libapache2-mod-jk
  • Create a file /etc/apache2/conf.d/jk.conf with the following content:
JkWorkersFile   /etc/apache2/jk-workers.properties
JkLogFile       /var/log/apache2/mod_jk.log
JkShmFile       /var/log/apache2/mod_jk.shm
JkLogLevel      warn
JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories
JkRequestLogFormat "%w %V %T"
JkMount /openbravo* ajp13
JkMountCopy all
  • Create a file /etc/apache2/jk-workers.properties with the following content:
# workers.properties
worker.list=ajp13
worker.ajp13.port=8009
worker.ajp13.host=localhost
worker.ajp13.type=ajp13
worker.ajp13.lbfactor=1
  • Restart the web server
sudo /etc/init.d/apache2 restart

Notes

  • If you work with more than one context with different names you must add all the names in the jk.conf file, e.g. the ob240 and ob250 matches openbravo context name
JkMount /ob240* ajp13
JkMount /ob250* ajp13
  • I’m assuming that you only have 1 tomcat instance running, if not you’ll need to configure different port of the AJP13 connector in the server.xml, this must match with the worker port number worker.ajp13.port=8009. If you are using Eclipse, you can configure a different port on the Server definition.
 <Connector port="8009" enableLookups="false" redirectPort="8443" protocol="AJP/1.3" />
Advertisements

Written by katratxo

April 7, 2009 at 11:20 am

Posted in Openbravo

Tagged with , ,

2 Responses

Subscribe to comments with RSS.

  1. Just a quick note. To avoid problems with international characters when configuring the AJP/1.3 connector. Be sure to add the parameter:

    URIEncoding=”utf-8″

    This way the connector definition should be similar to this:

    Adrián Romero

    February 22, 2011 at 12:27 pm

    • Thanks for the info

      katratxo

      February 22, 2011 at 6:29 pm


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: