Jsp and PHP share port 80 to integrate Apache and Tomcat without adding a port number

Source: Internet
Author: User
: This article describes how to use port 80 for Jsp and PHP to integrate Apache and Tomcat without adding a port number. For more information about PHP tutorials, see. 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.2
Tomcat 7.0.37
Preparations:
Download mod_jk.so
Http://archive.apache.org/dist/tomcat/tomcat-connectors/jk/binaries/
Open the link and find the appropriate file to download. after the download, rename it mod_jk.so.
Modify Apache files
1. Upload mod_jk.so to the/modules Directory.
2. create the file mod_jk.conf in the/apache/conf directory.
# Load mod_jk module
LoadModule jk_module modules/mod_jk.so
# Where to find workers. properties
JkWorkersFile conf/workers. properties
# Where to put jk logs
JklogFile logs/mod_jk.log
# Set the jk log level [debug/error/info]
JkLogLevel info
# Select the log format
JkLogStampFormat "[% a % B % d % H: % M: % S % Y]"
# JkOptions indicate to send ssl key size,
JkOptions + ForwardKeySize + ForwardURICompat-ForwardDirectories
# JkRequestLogFormat set the request format
JkRequestLogFormat "% w % V % T"
# Send servlet for context/examples to worker named ajp13
JkMount/servlet/* ajp13
# Send all files under MyProject for to worker named ajp13
JKMount/MyProject ajp13
3. create the workers. properties file in the/apache/conf directory.
Worker. list = ajp13
Worker. ajp13.port = 8009
Worker. ajp13.host = localhost
Worker. ajp13.type = ajp13
Worker. 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.
Find DocumentRoot and remember its value, which will be useful later. My website is/www/apache/htdocs.
5. add Node

The code is as follows:



ServerAdmin webmaster@dummy-host.example.com
ServerName www.sample.cn/m
ProxyRequests Off

Order deny, allow
Allow from all

ProxyPass/MyProject http://www.sample.cn/MyProject/pages/login.jsp
ProxyPassReverse/MyProject http://www.sample.cn/MyProject/pages/login.jsp


[Note:] The name of the red part must be the same, that is, it must be the same as the project name under tomcat.
Modify Tomcat files
1. add ROOT. xml under tomcat
My directory is like this:/opt/tomcat/conf/Catalina/localhost
Create ROOT. xml

The code is as follows:





2. modify/conf/server. xml
I. modify the default port number (or do not change it. the default value is generally 8080)

II. check the AJP port number (8009 cannot be modified. if this sentence is commented out, uncomment it)

III. check Node

----------------------- 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"

.......................... Read the full text]

Java free learning Java self-learning http://www.javalearns.com

Follow #: javalearns learn Java at any time

Or scan

Learn Java at any time


The above introduces the Jsp and PHP shared port 80 integration Apache and Tomcat access without adding a port number, including the content, hope to be helpful to friends interested in PHP tutorials.

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.