PHP binds an ip address (such as 127.0.0.1) and multiple domain names (virtual hosts) to a 127.0.0.1 virtual host. PHP binds an ip address (such as 127.0.0.1) and multiple domain names (virtual hosts). Solution 1 of 127.0.0.1 virtual hosts: differentiate virtual hosts through ports ① bind one ip address (for example, 127.0.0.1) and multiple domain names (virtual hosts) by binding one PHP, 127.0.0.1 virtual host
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
Binding of hosts (such as 127.0.0.1) and multiple domain names (virtual hosts), 127.0.0.1 virtual host Solution 1: differentiate different virtual hosts through ports ① bind one...