Integration and Integration of Apache and Tomcat

xiaoxiao2021-03-06  41

I. First of all, I still quote a post of others, then do some instructions, and I will also ask you to correct it.

two.

Use Tomcat to do a JSP server alone, there will be problems in work efficiency, and the maximum number of concurrent connections that can withstand can also restriction; test, Tomcat will be "zombie" when concurrent connection is more Request the connection to lose a response. So now there are some "integration" solutions:

The HTML is clearly divided into workers, allow Tomcat only processes the JSP section, and other Web Server processing by Apache, IIS, which greatly saves Tomcat's limited work "thread".

Of course, these J2EE servers such as IBM WebSphere, BEA WebLogic, JBoss will be a better solution, but only the application EJB will play the powerful features of these J2EE servers.

So here, recommend Apache Tomcat's "gold combination". Find some information on the Internet, then do your own experiment, tossing for nearly one hour, finally got! The specific process is summarized as follows, I hope that everyone can help:

My Operation Environment: Windows2k Server SP4 J2SDK1.42 Apache2.049 Tomcat5.019 SQL Server2k

** Prepare software:

1, Apache 2.0.49 2, Tomcat 5.0.19 3, JK2 Connector (MOD_JK2.SO)

** Start installation: (The installation path here is optional, as long as you regard your actual situation, you can modify it)

Apache is installed under H: / Apache / Apache2, listening to port 80; Tomcat Under H: /Apache/tomcat5.0, listen to port 8080;

Both are installed in Windows NT services.

Copy mod_jk2.so to the H: / Apache / Apache2 / MODULES directory:

1. Edit the h: /apache/apache2/conf/httpd.conf file, add: in the LoadModule section:

LoadModule JK2_Module Modules / MOD_JK2.SO

2. Change AddDefaultCharset ISO-8859-1 to AddDefaultCharset GB2312 to automatically support Chinese display;

3. Add: (This configuration can be modified according to your actual situation)

ServerAdmin Pentium4xeon@etang.com

DocumentRoot "h: /apache/tomcat5.0/webapps/root"

ServerName www.sdg.com

Errorlog logs / sdg.com-error_log

Customlog logs / sdg.com-access_log common

** Write the Workers2.Properties file and join the H: / Apache / Apache2 / Conf directory, the content is as follows:

[SHM]

File = $ {serverroot} /logs/shm.file

SIZE = 1048576

#The socket channel

[Channel.socket: Localhost: 8009]

Port = 8009

Host = 127.0.0.1

#define the worker

[AJP13: Localhost: 8009] Channel = Channel.socket: Localhost: 8009

#uri mapping

[URI: / *. jsp]

Worker = ajp13: Localhost: 8009

** Due to the JK2.Properties file when Tomcat5.019 is installed, you don't have to write it yourself here. (Maybe this is one of the benefits of high versions * ^ _ ^ *)

** Write a normal HTML file (index.html) with a JSP file (TEST.JSP), put it under H: /apache/tomcat5.0/webapps/root; now it is best to restart your computer.

After restart, start Apache and Tomcat,

Http://www.sdg.com should be and

Http://www.sdg.com: 8080 is the same - the display is index.html;

You can now test Test.jsp,

Http://www.sdg.com/test.jsp, how, passed well?

** Test the Tomcat connection pool section below, copy all files (HTML JSP JAVABEAN Servlet) to h: /apache/tomcat5.0/webapps/root, configure Tomcat's server.xml file, add a connection pool . In my, after testing, all functional parts can work.

Download: MOD_JK2.SO

*********postscript*************************

1. If your home page is a JSP page, you still need to configure one:

DirectoryIndex index.html index.html.var index.jsp

Plus Index.jsp is available * ^ _ ^ *

2. WARNING:

------------ ** After integration, the work has been normal, but accidentally opened Apache's error.log file, was frightened for cold sweat ~~~~ There were many mistakes, there was one line Print:

No Such Channel Port: Localhost: 8019

..... AJP13XX FAILED!

Look at the worker2.properties file carefully and find a setting inside:

[AJP13: Localhost: 8019]

Channel = CHANNEL.SOCKET: Localhost: 8009

The wrong 8019 port is this ~ Immediately change 8019 to 8009 ~ There is no such problem now ~ It seems that online information is not necessarily the most accurate ... (may be a pen error ~ ~~): p

** --- I apologize for the inconvenience!

3. Discover a "small problem" on a configuration ----

A virtual host has a configuration: DocumentRoot item, if you follow

DocumentRoot "h: /apache/tomcat5.0/webapps/root" configuration, the host can work normally, but if you open the logs / sdg.com-error_log file, you will find a line error message:

** Warning: "h: //apache/tomcat5.0/Webapps/root" Doesn't exist!

After trying, if it is changed:

DocumentRoot "h: /apache/tomcat5.0/webapps/root" completely does not have any warning information to appear in an Error_log file ~

III. My own configuration and important parameters (WinXP Tomcat5.0.14 apache2.0.52):

Tomcat installation directory: f: / tomcat, there is an application item in WebApps Yedongshu

Apache installation directory: f: / apache2052

My Workers2.properties:

[SHM]

File = $ {serverroot} /logs/shm.file

SIZE = 1048576

#The socket channel

[Channel.socket: Localhost: 8009]

Port = 8009

Host = 127.0.0.1

#define the worker

[AJP13: Localhost: 8009]

Channel = CHANNEL.SOCKET: Localhost: 8009

# Map the tomcat examples Webapp to the Web Server Uri Space

[URI: / YEDONGDSHU / WEB-INF / *]

[URI: / *. jsp]

INFO = Map the whole WebApp

Description of Workers2.properties:

[URI: / YEDONGDSHU / WEB-INF / *]

[URI: / *. JSP] When encountered JavaBean, servlet, JSP, Apache is given to Tomcat processing.

My httpd.conf:

Modify the apache2 / conf / httpd.conf file in the installation directory,

1. Add: in the LoadModule section:

LoadModule JK2_Module Modules / MOD_JK2.SO

2. Change AddDefaultCharset ISO-8859-1 to AddDefaultCharset GB2312 to automatically support Chinese display;

3. In "httpd.conf final Add: (this configuration can be modified according to your actual situation)

ServerAdmin Yds@163.com

DocumentRoot "f: / tomcat / webapps / yedongshu"

ServerName 212.20.36.215

ErrorLog logs / my-error_log

Customlog Logs / My-Access_log Common

4. If your home page is a JSP page, you still need to configure one:

DirectoryIndex index.html index.html.var index.jsp

My Server.xml (f: /tomcat/conf/server.xml):

In the last , plus a line:

Path means that you can access, DocBase means your application project, I can use it here.

Http://212.20.36.215 directly accessed.

转载请注明原文地址:https://www.9cbs.com/read-71662.html

New Post(0)