: This article describes how to bind an ip address (for example, 127001) to multiple domain names (virtual hosts) in PHP. For more information about PHP tutorials, see. Solution 1: differentiate virtual hosts through ports
① Prepare for binding a site
1. first open your website (d:/myblog (stored in the myblog directory of drive d ))
2. configure the httpd. conf file (stored in the conf folder of the apache installation directory) and enable the httpd-vhosts.conf (remove the # sign before the second line ).
3. configure the httpd-vhosts.conf File (stored in the extra folder in the apache installation directory)
4. add the ing between ip address and domain name in the hosts file
C:/Windows/System32/drivers/etc/hosts
5. we recommend that you log out of DocumentRoot (the root directory of the document). in the httpd. conf file
6. test, enter "http://www.shunping1.com" in the browser to see the site home page
② Add a new domain name and bind it to the ip address:
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 VM.
3. make apache listen to port 81 in the httpd. conf file.
4. add a new domain name to the hosts file
5. test, enter http://www.shunping3.com: 80 in the browser (the port name must be added)
Solution 2: differentiate different domain names through ServerName
1. develop a new site d:/myblog2
2. in the httpd. conf file, enable apache to cancel listening to port 81 (add # in front or delete it directly)
3. add the configuration in the httpd-vhosts.conf File (note that the configuration here is different from solution 1)
4. other configurations remain unchanged
The preceding section describes how to bind an ip address (such as 127001) to multiple domain names (virtual hosts) in PHP, including related content. I hope to help my friends who are interested in PHP tutorials.