JSP and PHP share port 80, integrating Apache and tomcat

Source: Internet
Author: User
Purpose:

The integration of Apache and Tomcat allows both Java and PHP projects to share port 80. when accessing a website, you do not need to add a port number in the address bar.

Environment Description:Linux centos 32-bit Apache 2.2.2tomcat 7.0.37 Preparations:Download mod_jk.sohttp: // templates Modify Apache files1. Upload mod_jk.so to the/modules directory. 2. Create the file mod_jk.conf in the/Apache/conf directory.
# Load mod_jk moduleloadmodule jk_module modules/mod_jk.so # Where to find workers. propertiesjkworkersfile CONF/workers. properties # where to put JK logsjklogfile logs/mod_jk.log # Set the jk log level [debug/error/info] jkloglevel info # select the log formatjklogstampformat "[% A % B % d % H: % m: % S % Y] "# jkoptions indicate to send SSL key size, jkoptions + forwardkeysize + response-forwarddirectories # jkrequestlogformat set the request formatjkrequestlogformat "% w % v % t" # Send servlet for context/examples to worker named ajp13jkmount/servlet/* ajp13 # all send files under myproject for to worker named ajp13jkmount/myproject ajp13

3. Create the workers. properties file in the/Apache/conf directory.

Worker. List = ajp13worker. ajp13.port = 8009worker. ajp13.host = localhostworker. ajp13.type = ajp13worker. ajp13.lbfactor = 1

4. Modify/CONF/httpd. conf

Change Listen 80 to listen your IP address: 80 servername localhost: 80 add include CONF/mod_jk.conf in the last line to find DocumentRoot and remember its value, which will be useful later. I added the <virtualhost> node to/www/Apache/htdocs5.

<Virtualhost *: 80>
Serveradmin webmaster@dummy-host.example.com
Servername www.sample.cn/m
Proxyrequests off
<Proxy *>
Order deny, allow
Allow from all
</Proxy>
Proxypass/myproject http://www.sample.cn/MyProject/pages/login.jsp

Proxypassreverse/myproject http://www.sample.cn/MyProject/pages/login.jsp

</Virtualhost> [Note:] The Name Of The Red part must be consistent, that is, it must be consistent with the project name under tomcat.
Modify Tomcat files1. Add root. xml under tomcat. My directory is like this:/opt/tomcat/CONF/Catalina/localhost new root. xml <? XML version = '1. 0' encoding = 'utf-8'?> <Context displayname = "Welcome to Tomcat" docbase = "" Path = "" DEBUG = "0"> </context> 2. Modify/CONF/server. xml I. modify the default port number (or do not change it. The default value is generally 8080) <connector Port = "9090" protocol = "HTTP/1.1" connectiontimeout = "20000" redirectport = "8443"/> II. check the AJP port number (8009 cannot be modified. If this sentence is commented out, uncomment it) <connector Port = "8009" protocol = "AJP/1.3" redirectport = "8443"/> III. check ----------------------- Friendly reminder ------------------------------------------------------------- Now, you can access the Java project through "Domain Name/project name/", but please note that the last "/" cannot be less! If you do not need to add "/", see "add a backslash after the website directory" Bytes ----------------------------------------------------------------------------------------------
Related Article

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.