The following describes how to configure a domain-name-based virtual host for apache on a local machine. if you need it, refer to Apache
1. open the httpd. conf file of apache and find
# Virtual hosts
# Include conf/extra/httpd-vhosts.conf
This section removes "#" before Include conf/extra/httpd-vhosts.conf.
2. modify the hosts file in the (win7) c:/windows/system32/drivers/etc/directory.
Add 127.0.0.1 x.acme.com (the domain name you use to access)
3. I use the wamp package, so go to the c:/wamp/bin/apache/Apache2.2.11/conf/extra directory.
Modify file httpd-vhosts.conf
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
Modify and restart the server.
Enter the http://x.acme.com in your browser to go to your Directory.
Of course, if you want to add a virtual host to an existing web server, if you want to use the localhost service, you need to add something to the above:
Add 127.0.0.1 localhost to the hosts file.
And add in the httpd-vhosts.conf file:
ServerAdmin localhost@xxx.com
DocumentRoot "/var/www /"
ServerName localhost
ErrorLog "log/localhost-error.log"
CustomLog "logs/localhost-access.log" common