Training, Open Source computer languages
PerlPHPPythonMySQLApache / TomcatTclRubyJavaC and C++LinuxCSS 
Search for:
Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
Python, Lua and Tcl - public course schedule [here]
Private courses on your site - see [here]
Please ask about maintenance training for Perl, PHP, Java, C, C++, Ruby, MySQL and Linux / Tomcat systems
Linking Apache and Tomcat

Posted by enquirer (enquirer), 21 June 2003
I have Servlets running via Tomcat (URLs on port 8080), and I'm also running Apache (standard port 80).  I want to be able to access my web applications looked after by Tomcat AND all the other clever stuff such as my PHP pages all on port 80.   How??

Posted by admin (Graham Ellis), 21 June 2003
You'll still need to run both Apache and Tomcat ... what you do is to load a module into Apache which causes it to call up Tomcat in turn if you call up a web page that's within Tomcat's remit.  As from release 4.x of Tomcat, it includes a WARP connector for the purpose - and from Tomcat 4.1 this is configured by default so there should be nothing to do there ...

What to do to Apache?

Firstly, you'll need a version of Apache that's running with dynamically loadable modules; most of them are today, but I'll add that caution just in case.   Then download the connector from the website - you're looking for the mod_webapp (a file called which you need to move into your apache modules directory.  note - you need the correct binary download for your operating system, and the apache module directory will be in different places on different OSs as well  

In the Apache configuration file, add
     LoadModule webapp_module modules/
after the last of the series of lines beginning LoadModule (line varies slightly on other OSs - above is Windows - on Linus last parameter is

After the AddModules line, add
     AddModule mod_webapp.c

At the end of the configuration file, add further configuration information - for example
    <IfModule mod_webapp.c>
    WebAppConnection sample warp localhost:8008
    WebAppDeploy firstapp sample /firstapp
    WebAppInfo /webappinfo

Restart Apache to bring in the new configuration - in our example, the deployed web application "firstapp" that's looked after by Tomcat will now also be made available as /firstapp through Apache.

Posted by admin (Graham Ellis), 24 June 2003
mod_webapp is quite a beast to configure and is very version dependent ... there's another alternative which gives you a quicker (but not so clean) linke between Apache and Tomcat - use the Rewrite engine of Apache.   Again, it's a very highly configurable piece of code - but here's a quick example that takes all requests within a directory called "tomdemo" on a virtual host called sole and switches them to the server running on port 8080 on the host computer dhansak.

DocumentRoot "/www/sole/html"
ServerName sole
ScriptAlias /cgi-bin/ "/www/sole/cgi-bin/"
RewriteEngine on
RewriteRule ^/tomdemo/(.*)$ http://dhansak:8080/firstapp/$1

With Rewrite, you can even use a URL on one computer to call up a URL on a different computer!

Posted by admin (Graham Ellis), 12 July 2003
I'm getting a lot of people asking about this topic.  With the configuration of both Apache httpd and Tomcat, there's much associated configuration too.  I'll continue to help / comment here but if anyone wants to come and study the subject, we're running a 2 day public course - see First course, 28th and 29th August.

Posted by admin (Graham Ellis), 11 September 2003
An update ... mod_webapp has been deprecated and is no longer the top recommendation for connection Apache httpd and Tomcat.

Options available and not deprecated:

a) Simply use a different port and have your web site use the correct URL - e.g.
        for the httpd server
    for Tomcat
[edit note - your browser may highlight the above links.  They're totally fictitious and don't take you anywhere ...]

b) Have Apache httpd proxy through to Tomcat, using http.  Quick and easy - a few configuration lines in httpd.conf and in server.xml

c) Use a jk2 connector, which ties the two servers together more closely.  The Tomcat configuration is easy (in server.xml), the httpd end requires you have a binary module for exactly the right release and operating system; either you'll need to strike lucky in finding one, or you'll end up recompiling httpd ....

This page is a thread posted to the opentalk forum at and archived here for reference. To jump to the archive index please follow this link.

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2018: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01225 708225 • FAX: 01225 793803 • EMAIL: • WEB: • SKYPE: wellho