Tomcat integration with Apache server under Windows system

  

The Apache server itself does not provide a Servlet/JSP container. Therefore, in practical applications, integrating Tomcat with the Apache server can create a commercially valuable Web platform with practical value.
Install Apache server

Run apache_2.0.63-win32-x86-no_ssl.msi, you will start the Apache server installation program, just install it according to the default settings. If the installation is successful, the Apache HTTP service will be automatically added to Windows.

Assuming the root directory of the Apache server is, there is a configuration file httpd.conf in its conf subdirectory. If Apache is installed on this machine and the default port 80 is used as the HTTP port, you will see the following properties in the httpd.conf file:

Listen 80

In the operating system Start]→[Program]→[Apache HTTP Server 2.0]→[ControApacheServer] menu provides submenus for restart, start and stop Apache servers.

Tips

You should make sure that port 80 of the operating system is not occupied, otherwise the Apache server will not start. Once the Apache server is started, you can determine if the installation was successful by accessing the Apache test page.

Add JK plugin to Apache server

To add JK plugin to Apache server, just copy mod_jk.so to /modules directory.

Create workers.properties file

The Apache server treats Tomcat as a worker working for itself. The workers.properties file is used to configure Tomcat information, which is stored in /conf/workers.

properties. The workers.properties file is provided in the sourcecode/chapter26/windows_apache directory of the book's bonus CD. Its contents are as follows ("#" followed by comment information):

worker.list=worker1worker.worker1.port =8009 #Working port, if not occupied, do not modify worker.worker1.host=localhost #Tomcat server address worker.worker1.type=ajp13 #typeworker.worker1.lbfactor=1 #Load balancing factor

The above worker.list specifies the list of Tomcat servers. For example, "worker.list=worker1" means there is only one Tomcat server named "worker1". For example, "worker.list=worker1,worker2" means that there are two

Tomcat servers named "worker1" and "worker2". Worker.worker1.port and worker.worker1.host are used to set the properties of the Tomcat server named "worker1". If you want to set the port property of worker2, you can use the form "worker.worker2.port=8109".

Test Configuration

Restart the Tomcat server and Apache server, and access http://localhost/index.jsp through the browser. If the default home page of Tomcat appears, the configuration is successful. In addition, if the helloapp application has been released on the Tomcat server (copy the helloapp directory in the sourcecode/chapter26 directory of the book's bonus CD to the /webapps directory), you can visit http://localhost/helloapp/hello.htm If the hello.htm webpage of the helloapp application is returned normally, the configuration has been successful. If the configuration is incorrect, you can view the log information generated by the JK plugin, which helps to find the cause of the error. Set the log file location to /logs/mod_jk.log in the Apache server configuration file httpd.conf.

Copyright © Windows knowledge All Rights Reserved