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

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

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

    apache配置本地測(cè)試多網(wǎng)站域名與虛擬主機(jī)

    1、修改域名訪問(wèn)方式:

    運(yùn)行: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>

    否則會(huì)出現(xiàn)無(wú)權(quán)訪問(wèn)問(wèn)題。

    3、虛擬主機(jī)的配置
    (1)基于IP地址的虛擬主機(jī)配置
    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和多端口的虛擬主機(jī)配置
    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)單個(gè)IP地址的服務(wù)器上基于域名的虛擬主機(jī)配置:
    # 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)在多個(gè)IP地址的服務(wù)器上配置基于域名的虛擬主機(jī):
    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社區(qū)論壇

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

    (5)在不同的端口上運(yùn)行不同的站點(diǎn)(基于多端口的服務(wù)器上配置基于域名的虛擬主機(jī)):
    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的混合虛擬主機(jī)的配置:
    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>

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

    簡(jiǎn)單的說(shuō),打開httpd.conf 在最后加入如下內(nèi)容:

    <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" 為你的站點(diǎn)存放目錄:重啟apache2以后,你的虛擬主機(jī)就配置好了,以后就可以通過(guò)127.0.0.2,和127.0.0.3進(jìn)入不同的站點(diǎn)了。

    下面為詳細(xì)說(shuō)明分析:

    在我們安裝APACHE的時(shí)候一般默認(rèn)的apache的配置是只有一個(gè)網(wǎng)站,這樣切換起來(lái)很不方便。其實(shí)這個(gè)問(wèn)題很好解決,就是把本機(jī)的 apache配置成為虛擬服務(wù)器。但是,網(wǎng)上大多數(shù)教程的是教用 apache如何配置基于域名的虛擬主機(jī)的,而在本機(jī)調(diào)試網(wǎng)站的時(shí)候,一般都是用本地ip(127.0.0.1 或 localhost)直接訪問(wèn),沒有用到域名。所以得把a(bǔ)pache配置成為基于ip地址的虛擬主機(jī)。

    首先,我們都知道,所有以127打頭的ip地址都應(yīng)該指向本機(jī),并不只有127.0.0.1,這點(diǎn)大家可以試試。
    這樣一來(lái),也就是說(shuō)本機(jī)有足夠多的ip地址供你來(lái)開設(shè)虛擬主機(jī)了。

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

    3、虛擬主機(jī)配置段:在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、然后相應(yīng)的配置好各個(gè)目錄屬性,下面是一個(gè)目錄屬性的典型配置:
    <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以后,你的虛擬主機(jī)就配置好了,以后就可以通過(guò)127.0.0.1和127.0.0.2,127.0.0.3進(jìn)入不同的站點(diǎn)了。

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


    只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。


    網(wǎng)站導(dǎo)航:
     
    <2025年5月>
    27282930123
    45678910
    11121314151617
    18192021222324
    25262728293031
    1234567

    導(dǎo)航

    留言簿(6)

    隨筆檔案

    文章分類

    文章檔案

    搜索

    最新評(píng)論

    閱讀排行榜

    主站蜘蛛池模板: 亚洲人成77777在线播放网站不卡| 24小时日本在线www免费的| 亚洲AV无码乱码精品国产| 亚洲色偷偷偷综合网| 131美女爱做免费毛片| 久久精品亚洲中文字幕无码网站| 亚洲精品成人片在线播放| 丰满人妻一区二区三区免费视频| 亚洲午夜激情视频| 亚洲国产一区在线观看| 美女视频黄的全免费视频网站| 18禁止看的免费污网站| 国产99在线|亚洲| 日韩一区二区三区免费体验| 国产成人高清亚洲一区久久| 亚洲国产一级在线观看| 亚洲伊人久久大香线焦| 女人18毛片特级一级免费视频 | 麻豆国产人免费人成免费视频| 亚洲精品无码不卡在线播放| 黄网站免费在线观看| 久久精品国产亚洲AV无码娇色| 特级无码毛片免费视频| 黄色片在线免费观看| 精品国产日韩亚洲一区91| 久久久久av无码免费网| 最近中文字幕mv免费高清视频8| 亚洲图片在线观看| 久久久久久噜噜精品免费直播| 成人啪精品视频免费网站| 天天综合亚洲色在线精品| 亚洲VA中文字幕无码一二三区| 丰满妇女做a级毛片免费观看| 国产av天堂亚洲国产av天堂 | 亚洲av无码片区一区二区三区| a级特黄毛片免费观看| 亚洲色偷偷av男人的天堂| 国产男女猛烈无遮挡免费网站| 亚洲一区在线视频观看| 99精品视频免费在线观看| 亚洲色最新高清av网站|