<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 丁克設計 閱讀(3308) 評論(0)  編輯  收藏 所屬分類: Apache技術文檔

    <2025年7月>
    293012345
    6789101112
    13141516171819
    20212223242526
    272829303112
    3456789

    導航

    留言簿(6)

    隨筆檔案

    文章分類

    文章檔案

    搜索

    最新評論

    閱讀排行榜

    主站蜘蛛池模板: 免费中文字幕视频| 中文字幕在线视频免费观看| 三年片在线观看免费观看大全动漫| 亚洲精品成人在线| 欧洲美女大片免费播放器视频| 成人黄动漫画免费网站视频| 自拍偷区亚洲国内自拍| 成人免费的性色视频| 亚洲国产高清视频在线观看| 欧洲乱码伦视频免费| 日本亚洲免费无线码| 青青青国产免费一夜七次郎| 亚洲精品第一国产综合亚AV| 日韩伦理片电影在线免费观看| 国产亚洲精品第一综合| 亚洲精品亚洲人成在线观看下载| 久久www免费人成精品香蕉| 亚洲大尺度无码无码专区| 美女内射无套日韩免费播放| 久久国产亚洲高清观看| 青娱乐免费在线视频| 亚洲AV无码一区二区一二区| 亚洲精品和日本精品| 久久99精品视免费看| 一区二区亚洲精品精华液| 免费人成年激情视频在线观看| 乱淫片免费影院观看| 日韩亚洲人成在线综合日本| 日韩欧毛片免费视频| 香港一级毛片免费看| 亚洲国产精品无码久久SM | 亚洲第一永久AV网站久久精品男人的天堂AV | 亚洲av永久无码精品三区在线4| 免费无码精品黄AV电影| 色屁屁www影院免费观看视频| 亚洲韩国精品无码一区二区三区| 日本最新免费网站| 黄色片网站在线免费观看| 久久久久久亚洲精品| 日韩黄色免费观看| 免费观看在线禁片|