Home >Backend Development >PHP Tutorial >Detailed explanation of local machine apache configuration of virtual host based on domain name_PHP tutorial
1. Open the httpd.conf file of apache and find
# Virtual hosts
#Include conf/extra/httpd-vhosts.conf
Include this section Remove the "#" in front of conf/extra/httpd-vhosts.conf.
2. Modify the hosts file located in the (win7)c:/windows/system32/drivers/etc/ directory
Add a paragraph: 127.0.0.1 x.acme.com (the domain name you use to access)
3. I use the wamp package, so go to c:/wamp/bin/apache/Apache2.2.11/conf Modify the file httpd-vhosts.conf in the /extra directory
The default NameVirtualHost is as follows:
NameVirtualHost *:80
Added:
ServerAdmin x@acme.com
DocumentRoot "/var/www/html"
ServerName x.acme.com
ErrorLog "logs/x.acme.com -error.log"
CustomLog "logs/x.acme.com-access.log" common
Change it and restart the server.
Enter http://x.acme.com in the browser to go to your directory.
Of course, if you want to add a virtual host to the existing web server, then the original localhost If the service is to be usable, you need to add something on top of the above:
Add: 127.0.0.1 localhost
to the hosts file and add:
DocumentRoot "/var/www/"
ServerName localhost
ErrorLog "logs/ localhost-error.log"
CustomLog "logs/ localhost-access. log" common