Configure Apache HTTP server2.2.4 and tomcat6.014

Source: Internet
Author: User
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:

  • Enablelookups: If the value is true, the specific remote computer name will be returned when request. getremotehost () is called. If it is set to false, the value will be a string-type IP address. The default value of this attribute is false for performance reasons.
  • Redirectport: if this value is set to true, Tomcat will forward the request to this port when the request meets <security-constraint> and requires SSL transmission.
  • Scheme: If SSL is used for transmission and the value is true, request. getscheme () will return HTTPS; otherwise, HTTP will be returned. The default value is HTTP.
  • Security: If the value is true and only SSL is used for transmission, true is returned when request. issecure () is called. Otherwise, false is returned.
  • Protocol: set this parameter to AJP/1.3, indicating that Apache can communicate with Apache through the AJP/1.3 protocol.

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 mod_jk, rename it mod_jk.so (for convenience only), and put it in the modules folder under the Apache installation directory.
  • Modify httpd. conf
  • Create worker. properties. Create a worker. properties file, open it in notepad, and add the following content to it:

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.