Today in the integrated environment with the virtual host, did not expect the virtual host opened, localhost unexpectedly can not access, the solution is this:
Instance one, Apache configure the localhost virtual host Step 1, open the Apache directory under HTTPd file (for example: D:\wamp\bin\apache\apache2.2.8\conf) with Notepad, find the following module # Virtual hosts #Include conf/extra/httpd-vhosts.conf Remove the previous #, This opens the Httpd-vhosts virtual host file. This time restart Wamp environment, unable to open localhost, need to be configured in httpd-vhosts.conf.  2, open the Httpd-vhosts file with Notepad, configure the localhost virtual host, refer to the Httpd-vhosts file instance, modify the following: serveradmin [Email protected] documentroot "D:\wamp\www" servername Localhost serveralias Localhost errorlog " Logs/dummy-host.localhost-error.log " customlog" Logs/dummy-host.localhost-access.log " common Modify the configuration as follows: DocumentRoot modified to the local WAMP environment of the WWW directory (such as: D:\WAMP\WWW) servername changed to Localhost3, Reboot Apache, find localhost can open normally, configure localhost is relatively simple. Example Two, Apache configuration test.biuuu.com Virtual Host step 1, as in the same way, the replication configuration code is modified as follows: ServeradMin [Email protected] documentroot e:\webroot\biuuu ServerName test.biuuu.com errorlog "Logs/dummy-host2.localhost-error.log" customlog "Logs/dummy-host2.localhost-access.log" common 2, open the host file (c \ windows\system32\drivers\etc\hosts), add a line of code 127.0.0.1 test.biuuu.com 3, open test.biuuu.com in the browser, found the following error 403 Forbidden Error Forbiddenyou "permission to Access/on This server. analysis: This is mainly the directory access permissions are not set, you need to set access to the directory! 4, open the httpd file, find the following statement options followsymlinks allowoverride None order Deny,allow deny from all Copy the above code, and make directory changes, put/replace with E:\WebRoot\biuuu, modify the VirtualHost code as follows test found in the browser or not open, prompted as above 403 Forbidden Error, modify the deny from all to allow from All 5, restart Apache, the virtual host configuration is successful! Attention to thingsItem 1, directory path, such as E:\WEBROOT\BIUUU2, access permissions, such as Upper deny from all modify to allow from All3,host file, configure virtual domain name host to point to 4,HTTPD file, open include Conf/extra /httpd-vhosts.conf module 5,httpd-vhosts files, configuring virtual hosts using Apache to configure Httpd-vhosts virtual hosts is simple for developers, but very important for reference only! ps:d:\wamp\alias can also configure the virtual domain name, and example two the same effect servername Blog.cc serveralias blog.cc documentroot "D:\wamp\www\blog" options all followsymlinks includesnoexec indexes directoryindex index.html index.htm default.htm index.php default.php index.cgi default.cgi index.shtml index.aspx Default.aspx & nbsp AllowOverride All order Deny,allow allow from all /////////////////////////////// environmental requirements Apache (HTTPD) My version is 2.4.3 Win32, you may need PHP engine module to test PHP website. Profiles Assume that you already know that the configuration of various parameters for main server in the httpd.conf file includes DocumentRoot, ServerAdmin, servername, and so on. Then it is convenient to configure the virtual host. For easy administration of the configuration file, there is a line in httpd.conf that contains the external configuration file:
Include conf/extra/httpd-vhosts.conf
This line is commented out by default, primarily for the configuration of the virtual host. So add the configuration contents of the virtual host in this file (httpd-vhosts.conf): If I store two websites under e:/etc/www/, one is ggicci.cn and the other is chongwuxingqiu.com. stored in the ggicci.cn directory and the chongwuxingqiu.com directory, respectively. I'm now going to configure ggicci.cn as a virtual host that takes up port 81, which means I need to enter localhost:81 to access the site (this article is only relevant for local testing and does not involve remote servers). Chongwuxingqiu.com the same to occupy Port 82. My configuration includes the following:
Listen Bayi # Monitor 81 port <virtualhost *:81> ServerAdmin [email protected] DocumentRoot "e:/etc/www/ ggicci.cn " # site root directory directoryindex index.html index.php # Homepage Index, because it is a PHP site, so add a. PHP # ServerName errorlog "logs/ggicci.cn-error.log" # error log Customlog "Logs/ggicci.cn-access.log" Common # Access log </virtualhost>listen 82<virtualhost *:82> ServerAdmin [email protected] documentroot "e:/etc/www/chongwuxingqiu.com" directoryindex index.html INDEX.JSP # JSP site, so add a. JSP # ServerName errorlog "Logs/chongwuxingqiu.com-error.log" customlog " Logs/chongwuxingqiu.com-access.log "Common jkmount/*.jsp Chongwuxingqiu # This is the MOD_JK directive, related to Tomcat </ Virtualhost>
Test results
#e:/etc/www/ggicci.cn/index.php<?php echo "ggicci.cn";?>
e:/etc/www/pet.com/index.jsp<! DOCTYPE html><%@ page contenttype= "text/html; Charset=utf-8 "%>
Apache Open Virtual host localhost unreachable