1. Preface:
Reference: http://www.cnblogs.com/liaokailin/p/3963603.html
The quoted blog has a more detailed description, and the combination of pictures, very vivid;
I'm only doing simple instructions and integration steps here.
2. Why integrate Apache and Tomcat
Apache and Tomcat are Web servers, but Apache can't explain Java, and Tomcat can, Tomcat is an extension of Apache
There are two main reasons:
2.1. Distribute processing to reduce the burden on the server
Static HTML is given to Apache for processing, while Java dynamic parts are handled by Tomcat
2.2. Security, no direct access to Tomcat, protection of resources
3. Software required for integration: APACHE,TOMCAT,JDK (because Tomcat is using the JDK), mod_jk.so (plug-ins associated with Apache and Tomcat) 3.1.mod_jk.so Baidu or Google, and then some downloaded
Download and place in C:\Program Files (x86) \apache software foundation\apache2.2\modules Directory
3.2. Download the JDK, then install and configure the environment variables
Here is not said, can refer to:http://jingyan.baidu.com/article/bea41d435bc695b4c41be648.html
3.3.Tomcat, it is recommended to use EXE version
The next step is to choose the path you installed when you are prompted to select the JDK or JRE.
There are also Tomcat managed accounts and passwords that you can enter.
3.4.Apache (Key)
Download Apache server to official website or other place, is an EXE file
The installation process is always the next step, but you can also refer to the contents of the reference
After installation, open C:\Program Files (x86) \apache software foundation\apache2.2\conf(depending on your installation directory) httpd.conf
File, add this sentence at the end of the include conf/mod_jk.conf(meaning to refer to mod_jk configuration file, can also be directly configured in httpd.conf, but not recommended)
Then create the mod_jk.conf file (also put in the Apache Conf directory, as the above configuration is Include conf/mod_jk.conf)
Add a bit of content to the file:
LoadModule jk_module modules/mod_jk.so//Load mod_jk.so
jkworkersfile conf/workers.properties//Another profile, one to be created manually, placed in the Conf directory
jklogfile logs/mod_jk.log//log file
<virtualhost *>
directoryindex index.html index.htm index.jsp index.action
errorlog logs/error_log.txt
Customlog Logs/access_log.txt Common
jkmount/*web-inf ajp13///here to pay attention to the/*web-inf to be based on their actual situation to configure,
jkmount/*.action ajp13//Here are just a few examples.
jkmount/servlet/* ajp13//If the path you are visiting is Localhost/testproject/servlet
jkmount/* AJP13//The configuration is jkmount/testproject/* ajp13
jkmount/*.jsp ajp13
jkmount/*.do ajp13
jkmount/*.action ajp13
jkmount/*.json ajp13
</VirtualHost>
----------------------------------------------------------------------------------
Then create a new Workers.properties file
The contents are as follows:
workers.tomcat_home=c:\program files\apache software foundation\tomcat 8.0//tomcat installation path
ps=/
Worker.list=ajp13
worker.ajp13.port=8009
Worker.ajp13.host=localhost
Worker.ajp13.type=ajp13
4. Test 4.1. Restart Apache and Tomcat first
Enter localhost in the browser,
If there is an It works! It means Apache is fine.
4.2. Use eclipse to write a servlet, then package it into a war format
Unzip the war file and put everything inside it into Tomcat's WebApps directory
Access directly through Tomcat, localhost:8080/your servlet's access path
If OK, try localhost/your servlet's access path.
Finally, remember to disable the 8080 port, so that later to access the contents of Tomcat, it can only be forwarded through Apache
Well, the integration is here, of course, if there is a problem, remember to read the log
Integration of Apache and Tomcat under Windows