The results and ramblings of research


Configuring mod_jk, Tomcat 7.0 and Apache 2.2

with 14 comments

Tomcat is awesome for deploying JAVA code in an HTTP web server environment. I truly believe that Tomcat is one of Apache Software Foundation’s (ASF) finest projects. However, most of us know that the base url for Tomcat ends with url:8080/webappname which is pretty cumbersome when passing around to friends. However the ASF also releases mod_jk which allows seamless integration between the Web Server and the JAVA container. At the end of this configuration, your application will be visible as url/webappname with the internal communication between the webserver and JAVA container hidden. For the purpose of our deployment we will assume the web application context is webapp*, i.e., http://hostname:8080/webapp/.

# Download mod_jk binary. Assumption here is CentOS x86_64 with httpd 2.2
$ wget
# Move binary to webserver modules folder. Typical HTTPD_HOME=/usr/lib64/httpd/
$ mv $HTTPD_HOME\modules
# Create symbolic link
$ ln -s $HTTPD_HOME\modules\ $HTTPD_HOME\modules\

Once the mod_jk binary is installed now we need to configure the webserver to use mod_jk. To this we need to add a configuration file

# Move to configuration folder. Typically HTTPD_CONF=/etc/httpd
$ cd $HTTPD_CONF/conf.d
#Create mod_jk configuration and add next codeblock into it
$ vi mod_jk.conf
# Ensure Httpd loads this configuration
$ cd $HTTPD_CONF/conf
# Check httpd configuration 
$ vi httpd.conf
# Ensure that the module folder $HTTP_CONF/conf.d is loaded. The httpd.conf file must contain the following
Include conf.d/*.conf

Now configure the mod_jk.conf using the following code

# Load mod_jk module
LoadModule    jk_module  modules/
# Where to find
JkWorkersFile /etc/httpd/conf/
# Where to put jk shared memory
JkShmFile     /var/log/httpd/mod_jk.shm
# Where to put jk logs
JkLogFile     /var/log/httpd/mod_jk.log
# Set the jk log level [debug/error/info]
JkLogLevel    info
# Select the timestamp log format
JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
# Send servlet for context /examples to worker named worker1
#JkMount  /examples/servlet/* worker1
# Send JSPs  for context /examples to worker named worker1
#JkMount  /examples/*.jsp worker1
JkMount /webapp* ajp13 
#Mount the webapp context

Now configure the file, by adding the following to /etc/httpd/conf/ Ensure the ports referred in this file match the tomcat server configuration.


Lastly, restart Apache Web Server, by issuing:

$ /sbin/service httpd restart

Your webapp will now be viewable at http://hostname/webapp


Written by anujjaiswal

June 15, 2011 at 12:50 am

Posted in Linux, Tomcat

Tagged with , ,

14 Responses

Subscribe to comments with RSS.

  1. Hi, i just follow you tutorial step by step and i had a problem just at the end, when i restart my apache server apear an error:

    “Syntax error on line 17 of /etc/httpd/conf.d/mod_jk.conf:
    JkMount takes 1-2 arguments, A mount point from a context to a Tomcat worker [FAIL]”

    the line 17 contains the following:
    JkMount /webapp* ajp13 #Mount the webapp context

    dou you have an idea of what can be the main cause of this issue?

    Victor Alonso

    September 20, 2011 at 9:20 pm

    • Hi Victor

      I think the problem is you havent changed the webapp to the name of the web application. Say you have a web application called helloworld.war that you put in the $TOMCAT_HOME/webapp folder. Once tomcat deploys this webapp it will unwar the webapp and create a folder webapps/helloworld. Mod_jk must be given this folder to mount. then the jkmount line will be
      JkMount /helloworld* ajp13

      Let me know if this works?



      September 23, 2011 at 10:28 pm

      • Thank you for your excellent article. A line in your article might be incorrect.

        JkMount /webapp* ajp13 #Mount the webapp context

        You cannot write a comment in the same line as your configuration expression. That might be why Victor found the error.


        July 26, 2012 at 5:28 am

      • Good eye. Thanks for pointing out the typo.


        August 16, 2012 at 3:09 pm

  2. Hi Anuj,

    Can you tell me the exact name of the mod_jk binary? In your guide, you have mentioned this as “” – I would like to know what the ‘x’ is here…



    May 3, 2012 at 8:19 am

    • I specifically use which is the binary for the most current httpd server on RHEL 5. You can find your version on linux using

      $ rpm -qa | grep httpd

      which will output



      July 3, 2012 at 3:34 pm

  3. Hi there! Do you use Twitter? I’d like to follow you if that would be okay. I’m absolutely enjoying
    your blog and look forward to new updates.

  4. hello there and thank you for your info – I have certainly picked up anything new from right here.
    I did however expertise some technical points using this web site, as I
    experienced to reload the web site lots of times previous to I could get it to load
    properly. I had been wondering if your hosting is OK?

    Not that I am complaining, but sluggish loading instances times will often affect your placement in
    google and could damage your quality score if advertising and marketing with
    Adwords. Well I’m adding this RSS to my e-mail and can look out for much more of your respective exciting content. Make sure you update this again soon.

    storage Unit auctions

    March 15, 2013 at 2:23 pm

  5. This is a good tip particularly to those fresh to the blogosphere.
    Simple but very precise information… Appreciate your
    sharing this one. A must read article!

    Web Design

    April 14, 2013 at 1:20 am

  6. My coder is trying to convince me to move to .net from PHP.
    I have always disliked the idea because of
    the expenses. But he’s tryiong none the less. I’ve been using Movable-type on
    a variety of websites for about a year and am anxious about switching to another
    platform. I have heard excellent things about blogengine.
    net. Is there a way I can transfer all my wordpress posts into it?
    Any kind of help would be really appreciated!

    • I think you can export your wordpress blog as xml from the Dashboard and import that into the site.


      May 21, 2013 at 11:21 am

  7. “Configuring mod_jk, Tomcat 7.0 and Apache 2.2 | The results and ramblings of research” was a great post.
    If merely there was a lot more web blogs like this excellent
    one on the web. Anyways, thanks a lot for your personal time, Shelley


    January 25, 2014 at 3:14 am

  8. hi anujjaiswal

    i did the above configuration but i am not able to access the my tomcat servers without port number.The two tomcat servers present in two virtual machines but tomcat webserver is running in my machine.


    March 19, 2014 at 11:52 pm

    • Hi Srinivas,
      I am not sure I follow and sorry for the delayed response. In case you still have this issue, I would love if you could explain your configuration a little more in detail. The above configurations work in VM’s (AWS). Are you running this on two seperate VM’s locally? Please clarify.


      July 14, 2014 at 2:50 pm

Leave a Reply

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

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

Google photo

You are commenting using your Google 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 )

Connecting to %s

%d bloggers like this: