使用的wamp版本是:
wampserver2.5-Apache-2.4.9-Mysql-5.6.17-php5.5.12-64b.exe
前提工作
安装好wamp之后,调试出localhost站点。
修改本机的hosts文件
修改本机的hosts文件,如下(映射的域名根据自己的需要改)
PS:本步骤仅为配置本机访问用,如果已经准备好域名并且绑定了公网IP,跳过这一步。
在文件的最下面加上两行(想配置的域名)
127.0.0.1 www.xxx127.com 127.0.0.1 www.ooo127.com
变成像下面这样:
127.0.0.1 localhost 127.0.0.1 www.xxx127.com 127.0.0.1 www.ooo127.com 配置apache
打开wamp的安装目录,找到C:wampbinapacheapache2.4.9confhttpd.conf文件,分别去掉下面两行文字前面的#号。
LoadModule vhost_alias_module modules/mod_vhost_alias.so #去掉#意思是启用apache的虚拟主机功能。 Include conf/extra/httpd-vhosts.conf #去掉这一行的#意思是从conf/extra/httpd-vhosts.conf这个文件导入虚拟主机配置。
若要从外网访问,需要修改下面的配置:
保证下面三个地方都是Require all granted
#大约240行左右 <Directory /> AllowOverride none Require all granted </Directory> #大约280行左右 # onlineoffline tag – don\\\’t remove # Require local Require all granted </Directory> #大约388行左右 <Directory "c:/wamp/bin/apache/apache2.4.9/cgi-bin"> AllowOverride None Options None Require all granted </Directory> 配置虚拟目录
打开C:wampbinapacheapache2.4.9confextrahttpd-vhosts.conf文件,把默认的配置
<VirtualHost *:80> ServerAdmin webmaster@dummy-host.localhost DocumentRoot "/www/docs/dummy-host.localhost" ServerName dummy-host.localhost ServerAlias http://www.dummy-host.localhost/ ErrorLog "logs/dummy-host.localhost-error_log" CustomLog "logs/dummy-host.localhost-access_log common" </VirtualHost> <VirtualHost *:80> ServerAdmin webmaster@dummy-host2.localhost DocumentRoot "/www/docs/dummy-host2.localhost" ServerName dummy-host2.localhost ErrorLog "logs/dummy-host2.localhost-error_log" CustomLog "logs/dummy-host2.localhost-access_log common" </VirtualHost>
删除,改成下面的内容(根据自己的需要改)
<VirtualHost *:80> ServerAdmin localhost DocumentRoot "C:/wamp/www/" ServerName localhost ServerAlias localhost ErrorLog "logs/localhost-error_log" </VirtualHost> <VirtualHost *:80> ServerAdmin localhost DocumentRoot "C:/wamp/vhosts/xxx127.com/" ServerName www.xxx127.com ServerAlias *.xxx127.com ErrorLog "logs/xxx127-error_log" </VirtualHost> <VirtualHost *:80> ServerAdmin localhost DocumentRoot "C:/wamp/vhosts/ooo127.com/" ServerName www.ooo127.com ServerAlias *.ooo127.com ErrorLog "logs/ooo127-error_log" </VirtualHost> 重启wamp
到这一步,本机的多域名访问配置完成。
就可以在浏览器输入www.xxx127.com访问你设定好的目录下面的站点了
有问题欢迎留言。
更多关于云服务器,域名注册,虚拟主机的问题,请访问西部数码官网:www.west.cn