<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    apache配置本地測試多網站域名與虛擬主機

    1、修改域名訪問方式:

    運行:C:\WINDOWS\system32\drivers\etc

    打開:hosts文件

    添加域名指向。

    2、修改httpd.conf.

    配置生效前提,必須修改跟目錄為:

    <Directory />
    Options FollowSymLinks
    AllowOverride None
    ### Order deny,allow
    ### Deny from all
    Order allow,deny
    Allow from all
    Satisfy all
    </Directory>

    否則會出現無權訪問問題。

    3、虛擬主機的配置
    (1)基于IP地址的虛擬主機配置
    Listen 80
    <VirtualHost 172.20.30.40>
    DocumentRoot /www/example1
    ServerName www.example1.com
    </VirtualHost>
    <VirtualHost 172.20.30.50>
    DocumentRoot /www/example2
    ServerName www.example2.org
    </VirtualHost>

    (2) 基于IP和多端口的虛擬主機配置
    Listen 172.20.30.40:80
    Listen 172.20.30.40:8080
    Listen 172.20.30.50:80
    Listen 172.20.30.50:8080

    <VirtualHost 172.20.30.40:80>
    DocumentRoot /www/example1-80
    ServerName www.example1.com
    </VirtualHost>

    <VirtualHost 172.20.30.40:8080>
    DocumentRoot /www/example1-8080
    ServerName www.example1.com
    </VirtualHost>

    <VirtualHost 172.20.30.50:80>
    DocumentRoot /www/example2-80
    ServerName www.example1.org
    </VirtualHost>

    <VirtualHost 172.20.30.50:8080>
    DocumentRoot /www/example2-8080
    ServerName www.example2.org
    </VirtualHost>

    (3)單個IP地址的服務器上基于域名的虛擬主機配置:
    # Ensure that Apache listens on port 80
    Listen 80

    # Listen for virtual host requests on all IP addresses
    NameVirtualHost *:80

    <VirtualHost *:80>
    DocumentRoot /www/example1
    ServerName www.example1.com
    ServerAlias example1.com. *.example1.com
    # Other directives here
    </VirtualHost>

    <VirtualHost *:80>
    DocumentRoot /www/example2
    ServerName www.example2.org
    # Other directives here
    </VirtualHost>

    (4)在多個IP地址的服務器上配置基于域名的虛擬主機:
    Listen 80

    # This is the "main" server running on 172.20.30.40
    ServerName server.domain.com
    DocumentRoot /www/mainserver

    # This is the other address
    NameVirtualHost 172.20.30.50

    <VirtualHost 172.20.30.50>
    DocumentRoot /www/example1
    ServerName www.example1.com
    # Other directives here …
    </VirtualHost>
    IXDBA.NET社區論壇

    <VirtualHost 172.20.30.50>
    DocumentRoot /www/example2
    ServerName www.example2.org
    # Other directives here …
    </VirtualHost>

    (5)在不同的端口上運行不同的站點(基于多端口的服務器上配置基于域名的虛擬主機):
    Listen 80
    Listen 8080

    NameVirtualHost 172.20.30.40:80
    NameVirtualHost 172.20.30.40:8080

    <VirtualHost 172.20.30.40:80>
    ServerName www.example1.com
    DocumentRoot /www/domain-80
    </VirtualHost>

    <VirtualHost 172.20.30.40:8080>
    ServerName www.example1.com
    DocumentRoot /www/domain-8080
    </VirtualHost>

    <VirtualHost 172.20.30.40:80>
    ServerName www.example2.org
    DocumentRoot /www/otherdomain-80
    </VirtualHost>

    <VirtualHost 172.20.30.40:8080>
    ServerName www.example2.org
    DocumentRoot /www/otherdomain-8080
    </VirtualHost>

    (6)基于域名和基于IP的混合虛擬主機的配置:
    Listen 80

    NameVirtualHost 172.20.30.40

    <VirtualHost 172.20.30.40>
    DocumentRoot /www/example1
    ServerName www.example1.com
    </VirtualHost>

    <VirtualHost 172.20.30.40>
    DocumentRoot /www/example2
    ServerName www.example2.org
    </VirtualHost>

    <VirtualHost 172.20.30.40>
    DocumentRoot /www/example3
    ServerName www.example3.net
    </VirtualHost>

    ==========================================================================

    簡單的說,打開httpd.conf 在最后加入如下內容:

    <VirtualHost 127.0.0.2:80>
        DocumentRoot d:/AppServ/www2
        ServerName 127.0.0.2:80
    </VirtualHost>


    <Directory "d:/AppServ/www2">
        Options Indexes FollowSymLinks Multiviews
        AllowOverride All
        Order Allow,Deny
        Allow from all
    </Directory>

    "d:/AppServ/www2" 為你的站點存放目錄:重啟apache2以后,你的虛擬主機就配置好了,以后就可以通過127.0.0.2,和127.0.0.3進入不同的站點了。

    下面為詳細說明分析:

    在我們安裝APACHE的時候一般默認的apache的配置是只有一個網站,這樣切換起來很不方便。其實這個問題很好解決,就是把本機的 apache配置成為虛擬服務器。但是,網上大多數教程的是教用 apache如何配置基于域名的虛擬主機的,而在本機調試網站的時候,一般都是用本地ip(127.0.0.1 或 localhost)直接訪問,沒有用到域名。所以得把apache配置成為基于ip地址的虛擬主機。

    首先,我們都知道,所有以127打頭的ip地址都應該指向本機,并不只有127.0.0.1,這點大家可以試試。
    這樣一來,也就是說本機有足夠多的ip地址供你來開設虛擬主機了。

    廢話少說,進入正式的配置工作,下面是apache的httpd.conf里相關配置部分( httpd.conf 位于 Apache2.2\conf ):
    1、Listen部分,必須直接指定端口,不指定ip地址,配置應寫為:
    Listen 80
    2、不用像基于域名的虛擬主機那樣寫“NameVirtualHost”。

    3、虛擬主機配置段:在httpd.conf 最后加上
    <VirtualHost 127.0.0.2:80>
        DocumentRoot d:/AppServ/www2
        ServerName 127.0.0.2:80
    </VirtualHost>

    <VirtualHost 127.0.0.3:80>
        DocumentRoot d:/AppServ/www3
        ServerName 127.0.0.3:80
    </VirtualHost>...

    4、然后相應的配置好各個目錄屬性,下面是一個目錄屬性的典型配置:
    <Directory "d:/AppServ/www2">
        Options Indexes FollowSymLinks Multiviews
        AllowOverride All
        Order Allow,Deny
        Allow from all
    </Directory>

    <Directory "d:/AppServ/www3">
        Options Indexes FollowSymLinks Multiviews
        AllowOverride All
        Order Allow,Deny
        Allow from all
    </Directory>

    重啟apache2以后,你的虛擬主機就配置好了,以后就可以通過127.0.0.1和127.0.0.2,127.0.0.3進入不同的站點了。

    posted on 2010-10-09 12:39 丁克設計 閱讀(3303) 評論(0)  編輯  收藏 所屬分類: Apache技術文檔

    <2025年5月>
    27282930123
    45678910
    11121314151617
    18192021222324
    25262728293031
    1234567

    導航

    留言簿(6)

    隨筆檔案

    文章分類

    文章檔案

    搜索

    最新評論

    閱讀排行榜

    主站蜘蛛池模板: 黑人粗长大战亚洲女2021国产精品成人免费视频 | 成人黄色免费网址| 7777久久亚洲中文字幕蜜桃| 免费国产在线视频| 亚洲av综合色区| 久久A级毛片免费观看| 亚洲成a人片在线观看中文app| 日韩在线播放全免费| 亚洲日本国产综合高清| 免费无码看av的网站| 久久综合亚洲色hezyo| 国产一区视频在线免费观看| 亚州**色毛片免费观看| 亚洲AV一宅男色影视| av无码免费一区二区三区| 亚洲一区二区三区高清视频| 日韩视频在线免费观看| 一区二区三区免费看| 国产亚洲人成网站在线观看不卡| 久久爰www免费人成| 中文文字幕文字幕亚洲色| 国产无遮挡吃胸膜奶免费看| 一级做受视频免费是看美女 | 亚洲成人一区二区| 中文字字幕在线高清免费电影| 亚洲精品自产拍在线观看动漫| 午夜性色一区二区三区免费不卡视频| 亚洲中文字幕无码mv| 亚洲日韩在线观看免费视频| 特级无码毛片免费视频尤物| 亚洲综合中文字幕无线码| 人人狠狠综合久久亚洲高清| 最近更新免费中文字幕大全| 亚洲人成网站在线观看播放动漫| 国产猛烈高潮尖叫视频免费| 中国在线观看免费的www| 亚洲永久在线观看| 在线精品亚洲一区二区三区| 国产h视频在线观看网站免费| 一级毛片完整版免费播放一区| 亚洲视频在线一区二区三区|