Windows Apache2.4 and TOMCAT7 static and dynamic separation configuration

Source: Internet
Author: User

<1> Installation TOMCAT7, the official website download TOMCAT7 decompression version.

<2> Installation Apache2.4, the official website can download a compressed version of the decompression can also be downloaded from here.

The first step, open httpd.conf, modify the 38th row server path as shown

the path is the root directory where the server is installed as shown

then modify the 60th line and the No. 222 line of the port number, this random change, of course, can not change, I changed here to 8088, remember this port number, the following set VirtualHost can be used.

continue to modify the comment # 74 and 158 lines # Remove as shown

Add 171 line comments as shown

The second step, in the Conf folder to add static resource configuration file static-resource-proxy.conf, this file name arbitrary but need to be in the last line of HTTPD.CNF include, as shown


File Contents:

#添加服务器代理支持模块

LoadModule Proxy_module modules/mod_proxy.so
LoadModule Proxy_http_module modules/mod_proxy_http.so
#需要监听的虚拟地址, port number is consistent with httpd.conf because requests are distributed through the Apache server

<virtualhost *:8088>

ServerName 127.0.0.1 #服务名称
DocumentRoot "${srvroot}/htdocs/" #静态资源地址
ErrorLog Logs/webapp-error.log #日志相关
Customlog Logs/webapp-access.log Common
Proxyrequests off
Proxypass/resources/! #如果请求的url包含resources, the request is not forwarded and Apache handles it itself (that is, the static resource path)
proxypass/http://127.0.0.1:8080/#其他路径交给tomcat
proxypassreverse/http://127.0.0.1:8080/

# is important to keep each request in the same session
proxypassreversecookiepath/market//
</VirtualHost>

Principle thought: If the access path contains resources to Apache processing, does not contain resources to the Tomcat processing

The third step is to modify the Tomcat profile Server.xml to set the ajp/1.3 listening address to the IP that needs to be monitored, because I am testing locally, so I set it directly into 127.0.0.1 (other similar), as shown below


part fourth, testing

First put the static resources into the Apache Server Htdocs\resources folder as shown in

Then deploy the project to Tomcat (delete resources from the original project)


then start Tomcat and then start Apache .

The test below is the access to the static resources of the Apache server resource

The following accesses Non-static resources, which are accessed directly through Tomcat


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.