wampserver多站點配置

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 [email protected]
    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 [email protected]
    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
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章