Integration of Tomcat and Apache server under Windows system

Note: This article is a successful real experiment in reading. The book mentioned the incompatibility of different versions, but I'm glad I didn't encounter it. This example can be used for reference.

This article assumes that you already have a Java environment and tomcat, and you are familiar with the application of Tomcat.

Things to download

1. Apache: baidu searches Apache, enters the official website, looks for it, and then downloads it. What I download is: http://mirrors.cnnic.cn/apache//httpd/binaries/win32/httpd-2.0.65-win32-x86-no_ssl.msi

2. Download and install the JK plug-in (mod_jk connector), which is a plug-in provided by Tomcat development team to other web servers and Tomcat integration. Enter http://tomcat.apache.org , find Tomcat connectors in the download bar on the left and enter the download page to find the download link of the distribution. What I downloaded is: http://www.apache.org/dist/tomcat/tomcat-connectors/jk/binaries/windows/tomcat-connectors-1.2.39-windows-i386-httpd-2.0.x.zip

Install Apache

Double click the downloaded MSI file and go down step by step. In the middle, I need to set network name and service name. I write localhost. When I'm empty, I can write a mailbox. A command line window will pop up during this period. Don't worry. After the installation is completed, an additional one is added to the taskbar:

Put the JK plug-in in Apache

Unzip the downloaded JK rack package tomcat-connectors-1.2 39-windows-i386-httpd-2.0. x. Zip, there's a

Copy the file to / modules in the Apache directory. Next, start Apache

Enter in the browser: http://localhost/ (this' localhost 'is the network name that Apache has just installed.) if you get the following page, Apache installation is successful.

Set Tomcat and Apache integration configuration information

Open httpd.com in the Apache installation directory / conf directory Conf file, add the following configuration: # load JK plug-in module loadmodule JK_ module modules/mod_ jk. So # configure Tomcat server information jkworkerproperty worker list=worker1 JkWorkerProperty worker. worker1. port=8009 JkWorkerProperty worker. worker1. host=localhost JkWorkerProperty worker. worker1. type=ajp13 JkWorkerProperty worker. Worker1 #jk plug-in log directory jklogfile logs / Mod_ jk. Log #jk rack log level jkloglevel debug # set JK plug-in path mapping information jkmount / * jsp worker1

Start preparing for the test

1. Write an index in the webapps / root directory of Tomcat JSP write content: message from JSP; Writing an index HTML and write the content message from HTML

2. Start Tomcat

3. Enter in the browser http://localhost/index.jsp---- >Display message from JSP

input http://localhost/index.html---- >Display not found

Analysis: 1, why input: http://localhost/index.jsp Can display content

In the above steps, we wrote the following configuration for the Apache configuration file: jkmount / * jsp worker1

So * The request of JSP will be sent to Tomcat by JK plug-in for parsing and processing, and the local Tomcat is started. There is index. JSP under the webapps / root directory jsp

2. Why is there an index under webapps / root HTML and enter http://localhost/index.html Display not found

As explained in 1, * The JSP will have Tomcat to handle, and the requested index HTML will be handled by Apache, and there is no index. HTML under Apache HTML so not found

If you add an index. XML file to the HtDocs directory under Apache HTML revisit http://localhost/index.html The content can be displayed.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>