Apache-Tomcat integration on Ubuntu server « Intelligrape Groovy & Grails Blogs

Apache-Tomcat integration on Ubuntu server

Posted by admin

Follow the steps mentioned below to integrate Apache with Tomcat on an Ubuntu system. The steps assume that Apache and Tomcat are already installed and working fine independently.

  • Install Apache module for tomcat

sudo apt-get install libapache2-mod-jk

  • Create a file by the name “worker.properties” in /etc/apache2 directory. Sample worker.properties file below

workers.tomcat_home=/opt/servers/tomcat5.5
workers.java_home=/opt/java/jdk1.5
ps=/
worker.list=worker1
worker.default.port=8009
worker.default.host=localhost
worker.default.type=ajp13
worker.default.lbfactor=1

  • Add the following line to your site configuration file (/etc/apache2/sites-available/dellServer)

jkMount /* worker1

  • Add the following lines to the end of your /etc/apache2/apache2.conf file

LoadModule jk_module /usr/lib/apache2/modules/mod_jk.so
# Where to find workers.properties
JkWorkersFile /etc/apache2/workers.properties
# Where to put jk logs
JkLogFile /tmp/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"

  • Share/Bookmark
Tags: ,
This entry was posted on February 13th, 2008 at 1:37 am and is filed under Linux, System . You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

14 Responses to “Apache-Tomcat integration on Ubuntu server”

  1. Amit says:

    Hi there,
    This is a very useful tutorial. I searched a lot for making apache work with my tomcat, but couldnt make it work. But after reading this article, it was just a matter of minutes. and finally i got my apache work with tomcat.

    I really appreciate ur writing and wish u good luck. keep writing.

  2. AJ says:

    I have two websites on the same tomcat and apache. The rule JKMount /* just sends everything to tomcat. How do I configure workers.properties or httpd.conf to power two websites using mod_jk?

  3. JeyramoXRu says:

    Hi sirs ;-)
    Somebody can give me url to the XRumer’s homepage?
    Or maybe some info…

    Thank you very much!!!

    P.S. Вот уроды…

  4. Stephen Howe says:

    Modules are not “officially” loaded into apache this way in ubuntu and debian.
    The modules are either compiled or loaded at run-time.
    To see what modules are compiled in, use the command

    apache2 -l

    To load modules at run-time, two lines are added to the apache2.conf file located in the directory /etc/apache2/ in ubuntu.
    These are as follows:-
    # Include module configuration:
    Include /etc/apache2/mods-enabled/*.load
    Include /etc/apache2/mods-enabled/*.conf

    As you can see, apache loads any files ending with .load first and .conf after, in /etc/apache2/mods-enabled/.

    To make apache 2 load additional mods, you can manually create links from the directory mods-enabled to the directory mods-available for both “load” and “conf” files of the mod you need to load or you can use the command a2enmod which does it automatically.

    hence, in ubuntu or debian, you should actually add

    LoadModule jk_module /usr/lib/apache2/modules/mod_jk.so
    # Where to find workers.properties
    JkWorkersFile /etc/apache2/workers.properties
    # Where to put jk logs
    JkLogFile /tmp/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”

    to your jk.conf in /etc/apache2/mods-available/ directory and then check that the load command in jk.load is pointing to the right place
    i.e. mod_jk.so in the directory /usr/lib/apache2/modules

  5. Andi says:

    Thank you very much. Works within minutes..

  6. Gus says:

    I read with great interest your document. I been trying to make the connection for two days. Read many articles and documentation. I try you advice to the letter. Still it does not work for me. I’m Using Ubuntu Server and Tomcat v6. I do not know what else to do. The module is there, and working fine, Apache, and Tomcat are also working fine (but not together) what can I do to check where is the problem? Any suggestions?

  7. Sam says:

    Thanks much! Worked like a charm under Ubuntu.

    One change I made, for ubuntu concistency’s sake, was to move the line
    LoadModule jk_module /usr/lib/apache2/modules/mod_jk.so
    into apache2/mods-available/jk.load

    Next step for me is to tweak this into serving two tomcat instances hosting two appplications I want to keep in separate JVMs, as well as serve some static pages straight from apache without going through tomcat. Should be easy enough after this nicely done quick-start.

  8. coupon says:

    Important?…

    Is this really the latest?…

  9. Ume$h says:

    But , How to use apache pages.. i mean /var/www/test pages

  10. pumpkin carving patterns…

    [...]Apache-Tomcat integration on Ubuntu server « Intelligrape Groovy & Grails Blogs[...]…

  11. RDS Monitoring Needed: The remote desktop service is the prominent supply of danger of downtime

  12. Plogger base says:

    Plogger base…

    [...]Apache-Tomcat integration on Ubuntu server « Intelligrape Groovy & Grails Blogs[...]…

  13. hospedagem says:

    Hi! I found some errors in your site. Should I tell you what I think it’s wrong so that you may check this? Thanks – Claudia Hospedagem de site

  14. captcha sniper…

    [...]Apache-Tomcat integration on Ubuntu server « Intelligrape Groovy & Grails Blogs[...]…

Leave a Reply