Apache 配置多端口網站

跳過安裝步驟。php

1. apache安裝目錄/conf/httpd.conf,若是你是採用wamp集成環境,那麼在 wamp/bin/apache下。

2.  在httpd.conf中,找到  
    #LoadModule vhost_alias_module
    #Include conf/extra/httpd-vhosts.conf   
    去掉前面的#號,這一步是爲了加載擴展配置

3. 找到apache安裝目錄/conf/extra/httpd-vhosts.conf。
    打開文件找到 NameVirtualHost *:80,
    好比咱們要添加81的端口,在下面增長一行
    Listen 81

4. 而後找到<VirtualHost *:80> ... </VirtualHost> ,複製一段修改成
    <VirtualHost *:81>
    DocumentRoot "D:/php" 
    ServerName localhost
    ServerAlias localhost 
    </VirtualHost>

5. 配置目錄權限
    打開/conf/httpd.conf,找到Directory節點。
    能夠修改默認目錄權限,也能夠單獨指定目錄權限,分別是:
    修改默認目錄權限,即修改Directory節點
        <Directory />
            Options FollowSymLinks
         AllowOverride None
         Order deny,allow
       #Deny from all
         Allow from all
       #容許全部訪問
         Satisfy all
    </Directory>

    或者增長以下一段
<Directory "D:/php">
    #
    # 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.2/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:
    #   Options FileInfo AuthConfig Limit
    #
    AllowOverride all

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

#   onlineoffline tag - don't remove
    Order Allow,Deny
    Allow from all

</Directory>
6. 重啓apache服務,查看localhost:81/index.php 已經能夠正常運行了
相關文章
相關標籤/搜索