Apache Configuration Virtual Host VirtualHost multi-site

Source: Internet
Author: User
Tags install php tomcat

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.

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.