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
 
For 2023 (and 2024 ...) - we are now fully retired from IT training.
We have made many, many friends over 25 years of teaching about Python, Tcl, Perl, PHP, Lua, Java, C and C++ - and MySQL, Linux and Solaris/SunOS too. Our training notes are now very much out of date, but due to upward compatability most of our examples remain operational and even relevant ad you are welcome to make us if them "as seen" and at your own risk.

Lisa and I (Graham) now live in what was our training centre in Melksham - happy to meet with former delegates here - but do check ahead before coming round. We are far from inactive - rather, enjoying the times that we are retired but still healthy enough in mind and body to be active!

I am also active in many other area and still look after a lot of web sites - you can find an index ((here))
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., 2024: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho