[WebServer] Integration of Apache and Tomcat under Windows

Source: Internet
Author: User

Transferred from: http://bbs.blueidea.com/thread-2873268-1-1.html

Preparatory work:
1. Apache 2.2.4
: Http://cztele1.skycn.com/down/apache_2.2.4-win32-x86-no_ssl.zip

2. Tomcat 6.0.16
: http://apache.mirror.phpchina.co ... e-tomcat-6.0.16.zip

3. JDK
: Http://cds.sun.com/is-bin/INTERS ...-windows-i586-p.exe
If only the application, you can also choose to install the JRE, because the JRE is relatively small:)

4 jk-1.2.26-httpd-2.2.4
: Http://www.apache.org/dist/tomca ... 2.26-httpd-2.2.4.so
Note that the JK version must be the same as the Apache version. If your version and my different, can go to the official website to download, there are many versions, applicable to various operating systems, download the applicable can, address: http://www.apache.org/dist/tomcat/tomcat-connectors/jk/binaries/

To start the installation:
The installation order of the software can be adjusted appropriately, but the JDK (JRE) must be installed before Tomcat:

1. Installing the JDK (JRE)
The default, custom installation is available here. After the installation is complete, set your system environment variables as follows: My Computer, Properties----Advanced environment variables (System variables, non-user variables are added here)
Java_home = D:\Program files\java\jdk1.6.0_07
CLASSPATH =.; %java_home%\lib\tools.jar;%java_home%\lib\dt.jar;
PATH =%java_home%\bin;%path%
Note that the Java_home path changes to your actual installation path. The other two does not change.

2. Installing Apache
Note here that if you have IIS installed and have 80 ports, you can choose to disable IIS or specify a different port for IIS, or specify a different port for Apache to set according to the actual situation. In the Apache installation process to set up network domain and server name localhost, set your email address (this must be set, or Apache will not start up).
After installation, if Apache is using port 80, enter http://localhost in the browser, if you are using a different port such as 81, then enter http://localhost:81, you will see the success of Apache page. At this point Apache has run, in the system tray can see its icon, double-click Open can control Apache service, we also install Tomcat and JK, so now choose Stop Stop Apache service.

3. Install Tomcat
Unzip the Tomcat to D:\Program Files\tomcat and set the environment variable:
Catalina_base = D:\Program Files\tomcat
Catalina_home = D:\Program Files\tomcat
CLASSPATH =%catalina_home%\lib\servlet-api.jar
Running D:\Program Files\tomcat\bin\startup.bat launches Tomcat, and the Tomcat page indicates a successful installation.

4. Installing JK
Copy the mod_jk-1.2.26-httpd-2.2.4.so to the D:\Program files\apache2.2\modules.

The configuration of the server is as follows:
1. Configuring Tomcat
Look for the Conf/server.xml file under the Tomcat directory and add the following statement in <context path= "" docbase= "E:\wwwroot" reloadable= "true" crosscontext= "true"/>
Here, if path is not empty, the virtual directory is set, and the value of path is the virtual directory name.

Look for the conf/workers.properties file under the Tomcat directory and compare the text below, if there is a difference, modify it with the text below.
workers.tomcat_home=c:\apache-tomcat-6.0.18 #让mod_jk模块知道Tomcat的位置
Workers.java_home=d:\program files\java\jre1.6.0_07 #让mod_jk模块知道jre的位置
Ps=\
WORKER.LIST=AJP13 #模块版本
worker.ajp13.port=8009 #工作端口, do not modify if not occupied
Worker.ajp13.host=localhost #本机, if the above Apache host is not localhost, make the corresponding modification
WORKER.AJP13.TYPE=AJP13 #类型
Worker.ajp13.lbfactor=1 #代理数, no modification

If this file does not exist, it is created from the above content. Any changes to the Tomcat settings will be restarted to take effect.

2. Configure Apache
Open the httpd.conf under D:\Program files\apache2.2\conf, and at the end, add the following code and save it.
LoadModule Jk_module modules\mod_jk-1.2.26-httpd-2.2.4.so
#此处mod_jk的文件为你下载的文件
Jkworkersfile "D:\Program files\tomcat\conf\workers.properties"
#指定tomcat监听配置文件地址
Jklogfile "D:\Program Files\tomcat\logs\mod_jk2.log"
#指定日志存放位置
Jkloglevel Info

#设置虚拟主机
<virtualhost localhost>
#如果非虚拟主机, <virtualhost localhost> and final </VirtualHost> comments can be removed
ServerAdmin localhost
DocumentRoot E:/wwwroot
<directory "E:/wwwroot" >
#您的站点项目所在路径, should be the same as the directory settings in Tomcat, it is said that the above two must be set at the same time to take effect, there is no time to try different times what happens
ServerName localhost
DirectoryIndex index.html index.htm index.jsp
Errorlog Logs/shsc-error_log.txt
Customlog Logs/shsc-access_log.txt Common
jkmount/servlet/* ajp13
#让Apache支持对servlet传送, used for Tomcat parsing
Jkmount/*.jsp ajp13
#让Apache支持对jsp传送, used for Tomcat parsing
Jkmount/*.do ajp13
#让Apache支持对. Do transfer for Tomcat parsing
</VirtualHost>

#开头的行为注释, you can delete it. Here the configuration I was to set up the virtual directory, re-specify the Servername,documentroot path to configure the site, in fact, Apache configuration can be very flexible, you can also do not use the virtual directory, and directly to modify the default configuration of the site, Use any text editing tool, search for related items such as servername,documentroot,serveradmin, and then change the configuration of the item according to your actual situation. I recommend that you try a lot of different configurations, which is a fun experience.
After all the modifications are complete, double-click the Apache icon in the system tray and click Start to start the Apache service.
Enter http://localhost/in the address bar separately, and http://localhost:8080/if the results are the same, Apache and Tomcat are integrated successfully

Installation FAQs:
1. One boot Apache appears "Windows cannot start Apache2 on local computer" error
Most of the problem is the port, there may be other software use 80 port, it is best to change the Apache port to 81 port.

2.windows View 80 port occupancy, suitable for viewing any port
Start – Run –cmd enter Netstat-ano at the command prompt to see all connected PID and find the program corresponding to this PID in Task manager if there is no PID in Task Manager, you can select "View"-"Choose Column" in Task Manager, often We start the application when the system needs to find the port is occupied by other programs, how to know who owns the port we need, many people are more headache, the following is a very simple method, I hope it is useful to everyone.

We need to make sure who's taking our 80 ports.
Execute under Windows command-line window: C:\>netstat-aon|findstr "80″
See, Port is occupied by process number 2044 process, continue to execute the following command:
C:\>tasklist|findstr "2044″
Avp.exe 2044 Console 0 37,680 K
Very clear, AVP Kappa Monitor 80 port, adjust the Cat network monitoring settings.
Of course, if your 80 port is occupied by another program, kill or adjust the port.
Four finishes!

[WebServer] Integration of Apache and Tomcat under Windows

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.