Apache is the world's most popular web server. It is written in C/C++ which means it runs faster than Tomcat which is written in Java and is therefore interpretted on runtime.
Why use Tomcat then? You must use Tomcat in order to use Servlets and JSP pages. The Apache web server is a traditional web server which does not support JSP pages or Servlets. By linking these two servers together you gain the functionality of having Servlets and JSP pages, but benefit from the speed of Apache when delivering static content (E.g. Normal HTML pages).
There are currently two main version of Apache. There is Apache 1.3.x and 2.0. Apache 2.0 has been rewritten so that it is more stable on non-POSIX systems such as Windows.
Tomcat 4.0 currently has only one connector; the mod_webapp connector for apache 1.3. The AJP1.3 connector, mod_jk, can still be used, however.
TODO: tc4+apache 2.0
To use the mod_webapp connector the following must be done.
1. Check Apache's httpd.conf file
Make sure the ServerName and Port variables have been set. ServerName should be near the top of the file, but Port will be lower down as the value depends on whether you are running Apache proxied or not. For my httpd.conf (apache-1.3.20-6mdk) Port was on line 116. It will work with the two lines as follows (As a minimum, don't duplicate entries). Usually the defaults are fine, but make sure ServerName isn't commented out (Remove the leading # character).
2. Unzip the webapp module.
You should try to download the binary distribution related to your system. For example, I have downloaded webapp-module-1.0-tc40-linux-glibc2.2.tar.gz . The relevant files can be found by looking in the Tomcat binary downloads page hosted by Apache. Each operating system (that is widely used, anyway) has a subdirectory here where the webapp-module file can be found.
Now unzip this file into any temporary directory either by using Winzip (on Windows) or by doing:-tar xzf webapp-module-1.0-tc40-linux-glibc2.2.tar.gz
This will create the webapp-module-1.0-tc40 directory under which can be found the mod_webapp.so file which is the required Apache DSO module.
If there is no relevant download for your platform then you can build your own DSO from source code. This is described in the README.txt file found in the source distribution. I shall not describe it here, but may in future versions of this document.
3. Copy the DSO to Apache's modules directory.
Under Apache's home directory (/etc/httpd or /var/httpd on Linux, C:\Program Files\Apache Software Foundation\httpd ... I think ... on Windows) there should be a libexec directory. Some systems don't have this directory and will instead have a modules directory. The Windows distribution has both, but the webapp module should be copied in the modules directory. (Where the other .so files reside). Copy the file as so:-cp webapp-module-1.0-tc40/mod_webapp.so /etc/httpd/modules/
This command will, of course, vary from system to system.
4. Add to httpd.conf
Now edit your httpd.conf file again and add the following lines to it. These lines need to go after their counterparts in the file as follows :-
LoadModule vhost_alias_module modules/mod_vhost_alias.so LoadModule webapp_module modules/mod_webapp.so ... ClearModuleList ... AddModule mod_vhost_alias.c AddModule mod_webapp.c
There is a known possible problem with adding the AddModule line on the Windows platform. If errors are reported whilst starting Apache after adding this line then simply remove it.
Under Windows you will also need to copy the libapr.dll file into the modules directory.
5. Check syntax
Now you need to check that there are no errors in the modified file. To do this try running
This should report "Syntax OK". If it doesn't then check your httpd.conf file for errors and run the check again.
6. Add Web-App lines to httpd.conf
Now you will need to set some default settings for mod_webapp. As a start you will need to add the following lines to the end of your httpd.conf.
# Custom Tomcat mod_webapp stuff. WebAppConnection conn warp localhost:8008 WebAppDeploy examples conn /examples WebAppInfo /webapp-info
These lines instruct mod_webapp to connect to Tomcat 4 on port 8008, as defined in server.xml (We'll come onto this later). They also setup a default context for the bundled Tomcat examples, ehich are useful for testing. The final line is useful as it enables you to see the status of the container and information on who is currently connected to it. You can see this information by navigating to http://localhost/webapp-info/ .
TODO: Screenshot here