If we have only one server, how do we implement a request for this server to process both PHP and JSP?
The solution here is to port forwarding via the Apache virtual Host (vhost).
Apache forwards requests to different ports or different servers by accessing the domain name of the server.
0X00 Prerequisite & Purpose
Premise:
has a domain name, and has two a parsing, simultaneously resolves to this server's IP
Each has a JSP and PHP page (site)
Objective:
Parsing to PHP's Web site using php.test.com access
Resolve to JSP's Web site using jsp.test.com access
Operating system:
Centos 7.x If the previous version or other system may have a different situation
0X01 installation httpd (Apache)
Install and start a service
Yum Install httpd
Systemctl Start Httpd.service
0X02 Install PHP
Yum Install PHP
0X03 installation JDK to match JSP
Yum Install JAVA-1.8.0-OPENJDK
0X04 installation tomcat for parsing JSP pages
Yum Install Tomcat Tomcat-webapps Tomcat-admin-webapps
Systemctl Start Tomcat.service
0x05 configuration httpd used to support both PHP and JSP
Open configuration file
Vim/etc/httpd/conf/httpd.conf
Add the following on the front end of the configuration file
Namevirtualhost *:80
<virtualhost *:80>
ServerName php.test.com #指定一个域名
Documentroot/var/www/html #PHP网站的位置
ErrorLog Logs/php.test.com-error.log #日志位置
Customlog Logs/php.test.com-access.log Common #日志位置
</VirtualHost>
<virtualhost *:80>
ServerName jsp.test.com #指定另一个域名
Documentroot/var/lib/tomcat/webapps/root #JSP网站的位置
ErrorLog Logs/jsp.test.com-error.log #日志位置
Customlog Logs/jsp.test.com-access.log Common #日志位置
proxypass/http://127.0.0.1:8080/#转发位置
proxypassreverse/http://127.0.0.1:8080/#转发位置
</VirtualHost>
0X06 Last
Systemctl Restart Httpd.service
Systemctl Restart Tomcat.service
Now you can use php.test.com and jsp.test.com to access the PHP and JSP pages separately.