The software used in this article:
Apache HTTP Server 2.2
Tomcat 6
Mod_jk_apache2.2.4.so
The main task of this configuration is to connect Apache and tomcat. Therefore, the configuration work is divided into two parts: one is performed on Tomcat and the other is performed on Apache.
Tomcat configuration:
The configuration on Tomcat is relatively simple. It is nothing more than modifying the listening interfaces and protocols.
Procedure:
Open Server. xml and find the following line. If this line is commented out (in <! -- And -->), then the comment can be removed, and the final result can also be changed as follows: <! -- Define an ajp1.3 connector on port 8009 --> <connector Port = "8009" protocol = "AJP/1.3" rediredt = "8443"/>
Connector has the following attributes:
Apache configuration
To communicate with tomcat, Apache requires a plug-in. Currently, there are two types of plug-ins available: mod_jk and mod_proxy. Here we use mod_jk. here we need to note the version of mod_jk.
Download and configure mod_jk
Mod_jk can be downloaded at http://tomcat.apache.org/download-connectors.cgi. When downloading mod_jk, first find the directory corresponding to your operating system (such as the Win32 http://apache.freelamp.com/tomcat/tomcat-connectors/jk/binaries/win32/jk-1.2.28/), and then download the corresponding apache version of mod_jk according to the instructions below. Here I am using a mod_jk-1.2.28-httpd-2.2.3.so
Rename the downloaded mod_jk to mod_jk.so (for convenience) and put it in the modules folder under the Apache installation directory. Add the mod_jk.so command to Apache (by modifying httpd. conf)
Open the conf folder in the Apache installation directory, find httpd. conf, and open it in notepad. Add the following command at the end of the file:
Loadmodule jk_module modules/mod_jk.so
Save httpd. conf and restart Apache to load this module. For mod_jk.so, the following attributes need to be configured:
- Jkworkersfile specifies the location of the worker. properties file, for example, CONF/worker. properties.
- Jklogfile specifies the location of the mod_jk log file, such as logs/httpd/mod_jk.log.
- Jkloglevel specifies the Log Level of mod_jk. There are three levels: info, error, and Debug. Among them, info has the least log information and debug has the most
- Jkmount <URL to match> <Tomcat worker name> specifies which URL requests will be forwarded to Tomcat. <URL to match> the regular expression is used, and tomcat worker name is matched in the worker. properties file.
Here, we must add jkworkersfile and jkmount attributes. The configuration I use is as follows:
Jkworkersfile CONF/worker. Properties
Jkmount/examples/JSP/* worker1
Add a worker. properties file under the directory specified by jkworkersfile
Add the following content to it:
Worker. List = worker1
Worker. worker1.type = ajp13
Worker. worker1.host = 192.168.9.182
Here, the worker. worker1.host attribute must be set as your own IP address.
Test whether the connection between APACHE and Tomcat is successful.
Restart Apache and open http: // localhost/examples/JSP/. If the page appears the same as http: // localhost: 8080/examples/JSP, the configuration is successful.