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
 
This week, we're updating our course layouts and descriptions. Presentation and materials always gently change over time, but just occasionally there's a need to make a step change to clear out some of the old and roll in the new. That's now happening - but over a long and complex site it's not instant and you'll see sections of the site changing up to and including 19th September.

See also [here] for status update
 
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 jakarta.apache.org website - you're looking for the mod_webapp (a file called mod_webapp.so) 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/mod_webapp.so
after the last of the series of lines beginning LoadModule (line varies slightly on other OSs - above is Windows - on Linus last parameter is libexec.mod_wepapp.so)

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
    </IfModule>

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.

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


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 http://www.wellho.net/course/atfull.html. 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.
           http://www.sheepbingo.co.uk       for the httpd server
           http://www.sheepbingo.co.uk:8080   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 www.opentalk.org.uk 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., 2014: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 899360 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho