您的位置:首页 > 其它

wampserver多站点配置

2015-03-18 10:56 357 查看
1,打开C:\wamp\bin\apache\apache2.4.9\conf\extra\httpd-vhosts.conf

2,你会看到如下代码

# Virtual Hosts
#
# Required modules: mod_log_config

# If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn't need to worry about
# IP addresses. This is indicated by the asterisks in the directives below.
#
# Please see the documentation at
# <URL:http://httpd.apache.org/docs/2.4/vhosts/>
# for further details before you try to setup virtual hosts.
#
# You may use the command line option '-S' to verify your virtual host
# configuration.

#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for all requests that do not
# match a ServerName or ServerAlias in any <VirtualHost> block.
#
<VirtualHost *:80>
ServerAdmin webmaster@dummy-host.example.com
DocumentRoot "c:/Apache24/docs/dummy-host.example.com"
ServerName dummy-host.example.com
ServerAlias www.dummy-host.example.com
ErrorLog "logs/dummy-host.example.com-error.log"
CustomLog "logs/dummy-host.example.com-access.log" common
</VirtualHost>

<VirtualHost *:80>
ServerAdmin webmaster@dummy-host2.example.com
DocumentRoot "c:/Apache24/docs/dummy-host2.example.com"
ServerName dummy-host2.example.com
ErrorLog "logs/dummy-host2.example.com-error.log"
<pre name="code" class="cpp">    CustomLog "logs/dummy-host2.example.com-access.log" common
</VirtualHost>

复制最后一个标签

修改成如下

<VirtualHost *:80>
DocumentRoot "c:/Apache24/docs/dummy-host2.example.com"  //这个地址修改成你自己的WWW目录下的新站点文件夹
ServerName dummy-host2.example.com //这个是域名,随便改成你想要的
</VirtualHost>
3,打开保存

4,打开httpd.conf来让httpd-vhost.conf生效

5,在httpd,conf中查找“httpd-vhosts”

可以看到这段:

# Virtual hosts
# Include conf/extra/httpd-vhosts.conf


将include 前面的注释#去掉

注意:这里分为两种情况,一种为笔者自己新遇到解决的,网上没查到,另一种是网上可以查到的。

(这里可以解决服务器禁止的访问的问题)

第一种:(这是笔者遇到的情况)

找到一下内容:(可以通过查找directi)

<Directory />
AllowOverride all
Require all denied
</Directory>


将denied 修改为granted

第二种:

找到一下内容:

<Directory "f:/demo/">
#
# 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

#
# Controls who can get stuff from this server.
#

#   onlineoffline tag - don't remove
Require local
Order Deny,Allow
Deny from alll
Allow from 127.0.0.1
</Directory>



将Deny from all用#注释掉
将Allow from 127.0.0.1用#注释掉

下面添加一句 Allow from all

然后保存

6,就是在windows中的配置,可以让浏览器找到是本地的地址

打开 C:\Windows\System32\drivers\etc\hosts

在最后加入以下内容:

127.0.0.1  yourname.com //你刚才在httpd-vhosts.comf中创建的地址


然后保存。

7,重新打开wampserver,打开浏览器,输入你新建的地址,就可以进行测试了测试,别忘了在你得站点文件内写一个测试文件,不然不会有东西的.

CustomLog "logs/dummy-host.example.com-access.log" common

Require local
Order Deny,Allow
Deny from alll
Allow from 127.0.0.1
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: