How To Configure Tomcat to work with Apache
How to Connect Tomcat 6 to Apache HTTP Server 2
JkLogLevel trace JkMount /. loadbalancer JkMount /Jkmanager status Create workers.properties file. Define the list of Tomcat workers that can accept requests by adding the following configuration to the workers.properties file. Windows: NOTE 1: These instructions apply to integrating Apache HTTP server 2.2 in a Windows environment with Tomcat. NOTE 2: The instructions below reference C:Program Files (x86)Apache Software FoundationApache2.2 as the folder where Apache HTTP server is installed and C:Program FilesApache Software FoundationTomcat 7.0.29 as the folder where Tomcat is installed.
Tomcat can be run as a standalone server. Tomcat can also be run as an add-on to the Apache HTTP Server (or Microsoft IIS) - as the Java servlet/JSP container. In this combination, Tomcat executes the Java servlets and JSPs, the Apache serves the static HTML pages and performs other server-side functions such as CGI, PHP, SSI, etc. Read 'Why should I integrate Apache with Tomcat? (or not)' at Tomcat FAQ (http://wiki.apache.org/tomcat/FAQ/Connectors#Q3).
To configure Tomcat to work with Apache HTTP Server, you should first read the documentation provided in Tomcat thoroughly, and read the 'Tomcat Connector' documents @ http://tomcat.apache.org/connectors-doc.
To run Tomcat together with Apache:
- Apache needs to load a 'adapter' module, which uses a certain protocol, such as Apache JServ Protocol (AJP), to communicate with the Tomcat, via another TCP port (port 8009 in the default configuration).
- When Apache receives an HTTP request, it checks if the request belongs to Tomcat. If so, it lets the adapter takes the request and forwards it to Tomcat, as illustrated below.
There are a few adapter modules available, such as Apache JServ Protocol (AJP) v1.2 'JServ' module (outdated), AJP v1.3 'JK 1.2' module (in use) and 'JK 2' module (deprecated). I will only describe the JK1.2 module with Apache 2 here.
The step-by-step procedure is as follow:
Step 0.1: Install Apache HTTP Server - Refer to 'Apache HTTP Server - How To'. I shall assume that Apache is installed in directory '
d:myprojectapache', and runs on port 7000. I shall denote the apache installed directory as
Step 0.2: Install Tomcat - Refer to 'Tomcat - How To'. I shall assume that Tomcat is installed in directory '
d:myprojecttomcat', runs on port 8080. Tomcat's shall contains two web contexts: '
/examples' (Tomcat's servlets and JSP examples) and '
/ws' (to be created by you). I shall denote Tomcat's installed directory as
$CATALINA_HOME (Catalina is the code name for Tomcat 5 and above).
Step 1: Download the Apache-Tomcat Connector Module - An Apache-Tomcat connector - JK1.2 module - which is an adapter module used by Apache to communicate with Tomcat (using AJP v1.3 protocol through TCP port 8009), can be downloaded from Tomcat mother site @ tomcat.apache.org (⇒ Download ⇒ Tomcat Connectors ⇒ JK 1.2 ⇒ JK 1.2 Binary Releases ⇒ win32 ⇒ jk-1.2.xx ⇒ '
Rename the downloaded module to '
mod_jk.so' and move into directory '
Step 2: Configure Apache - We need to configure the Apache HTTP Server to load and initialize the JK module.
Create a configuration file called '
mod_jk.conf' as follows and place it in '
For each web context that is to be forwarded from Apache to Tomcat, include two
JKMount statements as shown. In the above configuration, Apache forwards all requests to web contexts '
/examples' and '
/ws' to Tomcat, via a 'worker' called '
ajp13'. (Check the URL of the Tomcat's servlet and JSP examples from the Tomcat's welcome page! It may move!)
Include the above configuration directives into the Apache's configuration by adding the following
include statement at the end of '
Note: Unix's forward slash is used as the directory separator instead of backward slash (because Apache was originally built for Unix). The
include statement simply appends all the statements from the file '
d:myprojecttomcatconfmod_jk.conf' into '
httpd.conf'. (You can of course add those statements into '
Next, observe that the configuration refers to a worker file called '
workers.properties', and forward certain requests to a JK worker called '
ajp13'. Create the '
workers.properties' file and place it in '
d:myprojecttomcatconf' as follows:
JKMount statements forward the requests to a worker called '
ajp13', which is defined in this '
Step 3: Configure Tomcat - The default configuration in Tomcat's '
confserver.xml' starts the AJP1.3 service via the following configuration, on TCP port 8009 (remove the comments if these lines are commented out).
Step 4: Start the Apache with the JK module
Check the Apache's log '
logserrors.log' to confirm that JK module was started:
Step 5: Start the Tomcat server
Observe that AJP1.3 service is initiated and the
ajp13 worker is listening at port 8009.
The order of starting up Tomcat and Apache is NOT important. Either apache or tomcat can be restarted at any time.
Step 6: Verify the Installation - Issue the following URLs to access the web contexts '
/examples' and '
/ws', that are defined in Tomcat (running in port 8080), but accessed via the Apache (running in port 7000).
REFERENCES & RESOURCES
- Apache-Tomcat Connectors @ http://tomcat.apache.org/download-connectors.cgi
- Apache-Tomcat Connectors Documentation
- Apache mother site @ www.apache.org
- Tomcat mother site @ tomcat.apache.org
Latest version tested: Apache 2.2.16 / Tomcat 7.0.2 / JK 1.2.30
Last modified: October, 2010
The following configuration steps apply to Windows/Linux/UNIX platforms.
Step 1: Run the PowerServer setup program and install PowerServer Web Component to the document root of the Apache HTTP Server, for example, %Apache%htdocs.
If you have installed PowerServer Web Component to another location, then you should copy the entire appeon folder from the installation directory of PowerServer Web Component to the Apache document root.
Step 2: Download the required plug-ins from http://archive.apache.org/dist/jakarta/tomcat-connectors/jk/binaries.
Step 3: Copy the downloaded plug-ins to the <APACHE>modules folder and rename it to mod_jk.so.
Step 4: Go to the <APACHE>conf folder, open the httpd.conf file with a text editor, and add the following script to the end of this file.
Step 5: In the <APACHE>conf folder, create the workers.properties file and add the following scripts to it.
Step 6: In the <APACHE>conf folder, create the redirector file mod_jk.conf and add the following scripts to it.
Step 7: Go to <JBossHome>standaloneconfiguration (for example, C:wildfly-18.0.0.Finalstandaloneconfiguration or C:applicationserverjboss-eap-6.4standaloneconfiguration), open the standalone.xml file with a text editor. Note that the scripts are different between JBoss EAP and Wildfly.
For JBoss EAP, find the following line:
Add the following line under the above line:
For Wildfly, find the following line:
Add the following line under the above line:
Step 8: Save the file and restart JBoss application server.
Step 9: Add the following scripts into the httpd.conf file in <Apache>conf folder:
In addition, remove the character '#' in front of the following script in the httpd.conf file:
Configuring DataWindow Data Cache (supports Windows platform only)
Log Level Debug
Under the installation directory of PowerServer Web Component (for example, C:Inetpubwwwrootappeon), there are Apache20Support and Apache22Support folders.
Copy the appeoncache.conf file from Apache20Supportconf or Apache22Supportconf to the %Apache%conf folder. And make the appropriate configuration under the instructions provided in the file.
Copy the modcache2.dll or modcache22.dll file from Apache20Supportmodules or Apache22Supportmodules folder to %Apache%modules folder.
Add the following script into the httpd.conf file in %Apache%conf folder to load appeoncache.conf and modcache2.dll or modcache22.dll:
Log Level Interpretation
|Configuring for single PowerServer||Home||Configuring Apache with JEUS|