整个配置涉及的文件有:(假设个人wamp安装D盘) php
C:/Windows/System32/drivers/etc 下的 hosts文件 html
D:/wamp/bin/apache/apache2.4.9/conf/extra 下的 httpd-vhosts.conf mysql
D:/wamp/bin/apache/apache2.4.9/conf 下的 httpd.conf web
步骤: sql
1.编辑httpd.conf apache
LoadModule php5_module "d:/wamp/bin/php/php5.5.12/php5apache2_4.dll"
PHPIniDir d:/wamp/bin/php/php5.5.12
Include conf/extra/httpd-vhosts.conf
查看这三句,若是它们被#注释了的话,去掉# (说明一下,第三句话通常注释的,去掉注释后就能开启配置站点)保存。 浏览器
此外,还有一个地方须要设置,wamp2.5默认只容许本地访问,咱们须要作的就是把本地改成所有均可以访问: 服务器
查找:<Directory "D:/wamp/www/">,找到 app
<Directory "E:/wamp/www/"> # # Possible values for the Options directive are "None", "All", # or any combination of: # Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews # # Note that "MultiViews" must be named *explicitly* --- "Options All" # doesn't give it to you. # # The Options directive is both complicated and important. Please see # http://httpd.apache.org/docs/2.4/mod/core.html#options # for more information. # Options Indexes FollowSymLinks # # AllowOverride controls what directives may be placed in .htaccess files. # It can be "All", "None", or any combination of the keywords: # AllowOverride FileInfo AuthConfig Limit # AllowOverride all Require all granted // 此处加上这段,表示容许全部访问站点 # # Controls who can get stuff from this server. # # onlineoffline tag - don't remove # Require local // 注释此处,目的是禁掉只容许本地访问 </Directory>
2.编辑 httpd-vhosts.conf
上面那步的第三句话就是让本文件的配置起做用 ide
咱们看到23~30行,这就是一个配置站点的范例,你能够参照它来写本身想要的站点信息:
<VirtualHost *:80> DocumentRoot "d:/wamp/www/demo/" // 此处表示网站代码根目录 ServerName www.demo1.com // 此处表示站点网址 </VirtualHost> <VirtualHost *:80> DocumentRoot "d:/wamp/www/web/" ServerName www.demo2.com </VirtualHost>
3.编辑 hosts文件
毕竟咱们的站点是在虚拟服务器上运行的,还得把咱们的服务名告诉机器
这最后一步就是告诉本主机你的站点名:
作法是在本文件最后添上
127.0.0.1 demo1.com
127.0.0.1 demo2.com
按照以上流程配置完之后,重启wamp全部服务,在浏览器输入demo1.com或demo2.com 就能访问到本身的站点了。