Under Windows to configure the virtual host and in the Linux configuration virtual host There are some differences, under Windows to find the httpd.conf file under the Conf directory, remove the corresponding comments, turn on the virtual machine, Windows default does not turn on the virtual machine.
Environment:
Windows7,apache 2.2.22
The configuration file used
1, Apache installation directory, conf/httpd.conf
2, Apache installation directory, conf/extra/httpd-vhosts.conf
3. C:\Windows\System32\drivers\etc\hosts file
Steps:
1, find the Apache installation directory conf/httpd.conf file, Notepad open, find the # Virtual hosts, remove the # below include, let the configuration file included in it. As follows:
# Virtual Hosts
Include conf/extra/httpd-vhosts.conf
2, find the C-disk, the Hosts file, add virtual host corresponding to the local domain name, as follows:
127.0.0.1 test.com
3. Locate the conf/extra/httpd-vhost.conf file in the Apache installation directory and add a VirtualHost
As follows:
<virtualhost *:80>
ServerAdmin [email protected] #管理员邮箱地址,
DocumentRoot "D:/www/wangzhan/test" #指定网站根目录, set up a test directory under Wangzhan
ServerName test.com #虚拟主机域名
Errorlog "Logs/dummy-host2.php100.com-error.log" #错误日志可以改成自己的路径
Customlog "Logs/dummy-host2.php100.com-access.log" common
</VirtualHost>
4, after the completion of the above 3 steps, restart Apache, then open the browser, enter test.com can access their own defined virtual host. Own test directory, build a PHP file for testing
This article is from the "Small City Studio" blog, please be sure to keep this source http://xcroom.blog.51cto.com/7941996/1650836
Configuring a virtual host under Windows