wamp配置虚拟主机

1.打开wamp中Apache2\conf\httpd.conf文件,将Include conf/extra/httpd-vhosts.conf前的#号去掉。

此时,若wamp重启不了,将httpd-vhosts.conf文件中的 CustomLog "logs/dummy-host2.localhost-access_log common" 去掉,common加在引号里面就会出错。

 
 
<VirtualHost *:80>
  ServerAdmin [email protected]
  DocumentRoot "D:\wamp\www\rewrite"
  ServerName dummy-host2.localhost
  ErrorLog "logs/dummy-host2.localhost-error_log"
  CustomLog "logs/dummy-host2.localhost-access_log common"
</VirtualHost>

2.找到wamp安装中的Apache2\conf\extra\httpd-vhosts.conf。添加如下代码:

 
 
<VirtualHost *:80>
  DocumentRoot "E:/www"
  ServerName www.iminda.com 
  ServerAlias www.iminda.com
  <directory "E:/www">
    Options FollowSymLinks
    AllowOverride all
    Order Deny,Allow
    Deny fromall
    Allow fromall
  </directory>
</VirtualHost>
3.打开系统文件目录:C:\WINDOWS\system32\drivers\etc 找到hosts文件。在最下面添加刚才配置的域名 使域名生效。如:
127.0.0.1 www.iminda.com自己可以根据需要多配置几个
4.重启apache服务。就ok了。
注意事项:
配置好以后原来的localhost就不可以使用了
只要在E:\wamp\bin\apache\apache2.2.8\conf\extra\httpd-vhosts.conf上添加
<VirtualHost *:80>
  ServerAdmin [email protected]
  DocumentRoot "e:/wamp/www"
  ServerName localhost 
  ServerAlias localhost
  ErrorLog "logs/www.njphp.cn-errlo.log"
  CustomLog "logs/www.njphp.cn-access.log" common
  <directory "e:/wamp/www">
    Options FollowSymLinks
    AllowOverride all
    Order Deny,Allow
    Deny from all
    Allow from all
  </directory>
</VirtualHost>
然后在C:\WINDOWS\system32\drivers\etc\hosts 把 #127.0.0.1 localhost 注释去掉或者加上这句


你可能感兴趣的:(安装,环境配置,wamp,虚拟主机)