Home > Backend Development > PHP Tutorial > PHP realizes the binding of an IP (such as: 127.0.0.1) and multiple domain names (virtual hosts), 127.0.0.1 virtual host_PHP tutorial

PHP realizes the binding of an IP (such as: 127.0.0.1) and multiple domain names (virtual hosts), 127.0.0.1 virtual host_PHP tutorial

WBOY
Release: 2016-07-13 09:46:57
Original
1069 people have browsed it

PHP implements the binding of an IP (such as: 127.0.0.1) and multiple domain names (virtual hosts), 127.0.0.1 virtual host

Solution 1: Through the port Distinguish between different virtual hosts

①Be prepared according to the method of binding a site

1. Develop your own website first (d:/myblog (stored in the myblog directory of D drive))

2. Configure the httpd.conf file (stored in the conf folder of the apache installation directory) and enable httpd-vhosts.conf (just remove the # sign in front of the second line).

3. Configure the httpd-vhosts.conf file (stored in the extra folder of the apache installation directory)

4. Add the corresponding relationship between IP and domain name in the hosts file

C:/Windows/System32/drivers/etc/hosts

5. It is recommended to log out of DocumentRoot (document root directory) in the httpd.conf file

6. Test, enter "http://www.shunping1.com" in the browser to see the homepage of the site

②Add a new domain name to bind to the IP:

1. Develop a new website: d:/myblog2

2. Configure the httpd.conf file (stored in the conf folder of the apache installation directory) and add a new virtual host

3. Always ask apache to listen to port 81 in the httpd.conf file

4. Add a new domain name in the hosts file

5. To test, enter "http://www.shunping3.com:80" in the browser (the port name must be added)

Solution 2: Distinguish different domain names through ServerName

1. Develop a new site d:/myblog2

2. Instruct apache to cancel monitoring port 81 in the httpd.conf file (add # in front or delete it directly)

3. Add configuration in the httpd-vhosts.conf file (note that the configuration here is different from the one in Solution 1)

4. Other configurations remain unchanged

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1029365.htmlTechArticlePHP implements the binding of an ip (such as: 127.0.0.1) and multiple domain names (virtual hosts), 127.0 .0.1 Virtual host solution one: Distinguish different virtual hosts through ports ① According to binding one...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template