Home  >  Article  >  Backend Development  >  PHP realizes the binding of an IP (such as: 127001) and multiple domain names (virtual hosts)

PHP realizes the binding of an IP (such as: 127001) and multiple domain names (virtual hosts)

WBOY
WBOYOriginal
2016-08-08 09:21:221497browse

Solution 1: Distinguish different virtual hosts through ports

① Prepare according to the method of binding a site

1. First develop your own website (d:/myblog (stored in the myblog directory of the 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. To test, enter "http://www" in the browser .shunping1.com" to see the site homepage

②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 apache conf folder in the installation directory), add a new virtual host

3. Always let apache listen on 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 the ServerName side

1 . Develop a new site d:/myblog2

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

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

4. The other configurations remain unchanged

The above introduces how PHP implements the binding of an IP (such as 127001) and multiple domain names (virtual hosts), including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement:
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