nginx下,乙個server標籤就是乙個虛擬主機。
3、基於ip的虛擬主機,幾乎不用。
需要建立/data/www /data/bbs目錄,windows本地hosts新增虛擬機器ip位址對應的網域名稱解析;對應網域名稱**目錄下新增index.html檔案;
nginx.conf配置檔案新增如下**:
server
server
驗證結果,使用curl測試,或者瀏覽器輸入網域名稱訪問;
# curl -xlocalhost:80 www.linuxidc.com
this is linuxidc linux
# curl -xlocalhost:80 bbs.linuxidc.com
this is linuxidc bbs
server
server
驗證結果,使用curl測試,或者瀏覽器輸入網域名稱訪問;
# curl www.linuxidc.com:8000
this is linuxidc linux
# curl www.linuxidc.com:8001
this is linuxidc bbs
基於ip位址的虛擬主機配置:
通過ip來訪問,需要配置多個ip;
# ifconfig eth0:1 192.168.22.21
server
server
驗證結果,使用curl測試,或者瀏覽器輸入網域名稱訪問;
# curl 192.168.22.20
this is linuxidc linux
# curl 192.168.22.21
this is linuxidc bbs
server}location ~ \.php(.*)$
}
注意:根目錄名字不能出現test這個詞
nginx配置虛擬主機的三種方式
3 基於ip的虛擬主機,幾乎不用。root localhost data tree ip 基於ip index.html num 基於埠 index.html www 基於網域名稱 1.php index2.html index.html index.php 1.windows本地hosts新增虛擬...
nginx 配置虛擬主機的三種方法
nginx下,乙個server標籤就是乙個虛擬主機。1 基於網域名稱的虛擬主機,通過網域名稱來區分虛擬主機 應用 外部 2 基於埠的虛擬主機,通過埠來區分虛擬主機 應用 公司內部 外部 的管理後台 3 基於ip的虛擬主機,幾乎不用。1 基於網域名稱配置虛擬主機配置 需要建立 data www dat...
Apache 配置虛擬主機三種方式
一 基於ip 1.假設伺服器有個ip位址為192.168.1.10,使用ifconfig在同乙個網路介面eth0上繫結3個ip root localhost root ifconfig eth0 1 192.168.1.11 root localhost root ifconfig eth0 2 1...