一個IP綁定多個域名(虛擬主機)設置方法


1.事先建立兩個域名站點

  分別建立web1和web2站點,分別建立主頁面web1.html和web2.html;

2.在httpd.conf文件中啟用httpd-vhosts.conf

  去掉#,即

#Virtual hosts (虛擬主機)
Include conf/extra/httpd-vhosts.conf

3.設置http-vhosts.conf文件(路徑:X:/ApacheX.X/conf/extra/http-vhosts.conf)

  添加以下內容:

#配置虛擬主機
<VirtualHost *:80> DocumentRoot "d:/web1" ServerName www.ayee1.com
    #配置歡迎首頁面
    DirectoryIndex web1.html index.html index.htm index.php
    <Directory />
    Options FollowSymLinks
    #不許別人修改網站頁面
    AllowOverride None
    #設置訪問權限
    Order allow,deny
    Allow from all
    </Directory>
</VirtualHost>

#配置虛擬主機
<VirtualHost *:80> DocumentRoot "d:/web2" ServerName www.ayee2.com
    #配置歡迎首頁面
    DirectoryIndex web2.html index.html index.htm index.php
    <Directory />
    Options FollowSymLinks
    #不許別人修改網站頁面
    AllowOverride None
    #設置訪問權限
    Order allow,deny
    Allow from all
    </Directory>
</VirtualHost>

4.在hosts文件中添加我們的ip和主機映射關系(路徑:c:/windows/system32/drivers/etc/hosts)

  在 127.0.0.1  localhost下添加如下地址

127.0.0.1    www.ayee1.com
127.0.0.1    www.ayee2.com

配置完成。

現在就可以在同一個ip下訪問兩個域名(www.ayee1.com和www.ayee2.com)站點了。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM