nginx支持的虛擬主機(jī)有三種
創(chuàng)新互聯(lián)建站網(wǎng)站建設(shè)公司是一家服務(wù)多年做網(wǎng)站建設(shè)策劃設(shè)計(jì)制作的公司,為廣大用戶提供了成都網(wǎng)站建設(shè)、成都做網(wǎng)站,成都網(wǎng)站設(shè)計(jì),廣告投放平臺(tái),成都做網(wǎng)站選創(chuàng)新互聯(lián)建站,貼合企業(yè)需求,高性價(jià)比,滿足客戶不同層次的需求一站式服務(wù)歡迎致電。1、基于域名的虛擬主機(jī)
2、基于IP的虛擬主機(jī)
3、基于端口的虛擬主機(jī)
一、基于域名構(gòu)建
1、編譯安裝nginx服務(wù)
2、配置DNS域名解析服務(wù)
3、配置虛擬主機(jī)
a、創(chuàng)建自測(cè)網(wǎng)頁
[root@localhost?named]#?cd? [root@localhost?~]#?mkdir?-p?/var/www/html/kgc [root@localhost?~]#?mkdir?-p?/var/www/html/accp [root@localhost?~]#?ls?/var/www/html/accp??kgc [root@localhost?~]#?cd?/var/www/html/ [root@localhost?html]#?echo?"this?kgc?web"?>?kgc/index.html [root@localhost?html]#?echo?"this?accp?web"?>?accp/index.html
b、編輯nginx.conf配置文件
vim?/usr/local/nginx/conf/nginx.conf ????include?conf.d/*.conf; ????server?{ ????????listen?????????????80; ????????server_name??www.kgc.com; ????????charset?utf-8; ????????access_log??logs/www.kgc.com.access.log??; ????????location?/?{ ????????????root???/var/www/html/kgc; ????????????index??index.html?index.htm; ????????} ????????error_page???500?502?503?504??/50x.html; ????????location?=?/50x.html?{ ????????????root???html; ????????} ????} ????server?{ ????????listen?????????????80; ????????server_name??www.accp.com; ????????charset?utf-8; ????????access_log??logs/www.accp.com.access.log??; ????????location?/?{ ????????????root???/var/www/html/accp; ????????????index??index.html?index.htm; ????????} ????????error_page???500?502?503?504??/50x.html; ????????location?=?/50x.html?{ ????????????root???html; ????????} ????}c、重載服務(wù)
systemctl?restart?nginx netstat?-ntap?|?grep?80d、訪問測(cè)試
www.kgc.com www.accp.com二、基于端口
a、創(chuàng)建另一個(gè)端口的測(cè)試網(wǎng)頁
[root@localhost?~]#?cd?/var/www/html/ [root@localhost?html]#?echo?"this?is?kgc?8080?web"?>?kgc/index.html
b、編輯nginx.conf配置文件,僅修改監(jiān)聽地址
????server?{ ????????listen?????????????192.168.109.137:80; ????????server_name??www.accp.com; ????????charset?utf-8; ????????access_log??logs/www.accp.com.access.log??; ????????location?/?{ ????????????root???/var/www/html/accp; ????????????index??index.html?index.htm; ????????} ????????error_page???500?502?503?504??/50x.html; ????????location?=?/50x.html?{ ????????????root???html; ????????} ????} ????server?{ ????????listen?????????????192.168.109.137:8080; ????????server_name??www.accp.com; ????????charset?utf-8; ????????access_log??logs/www.accp8080.com.access.log??; ????????location?/?{ ????????????root???/var/www/html/accp8080; ????????????index??index.html?index.htm; ????????} ????????error_page???500?502?503?504??/50x.html; ????????location?=?/50x.html?{ ????????????root???html; ????????} ????}c、重載nginx服務(wù)
systemctl?restart?nginx netstat?-ntap?|?grep?80d、測(cè)試網(wǎng)頁
www.accp.com www.accp.com8080三、基于IP
1、修改網(wǎng)頁配置文件中的區(qū)域數(shù)據(jù)配置文件
vim?/var/named/kgc.com.zone systemctl?restart?named2、編輯nginx.conf中的配置,修改ip地址
?server?{ ????????listen?????????????192.168.109.137:80; ????????server_name??www.kgc.com; ????????charset?utf-8; ????????access_log??logs/www.kgc.com.access.log??; ????????location?/?{ ????????????root???/var/www/html/kgc; ????????????index??index.html?index.htm; ????????} ????????error_page???500?502?503?504??/50x.html; ????????location?=?/50x.html?{ ????????????root???html; ????????} ????} ????server?{ ????????listen?????????????192.168.109.134:80; ????????server_name??www.accp.com; ????????charset?utf-8; ????????access_log??logs/www.accp.com.access.log??; ????????location?/?{ ????????????root???/var/www/html/accp; ????????????index??index.html?index.htm; ????????} ????????error_page???500?502?503?504??/50x.html; ????????location?=?/50x.html?{ ????????????root???html; ????????} ????}c、重載nginx服務(wù)
systemctl?restart?nginx netstat?-ntap?|?grep?80d、測(cè)試網(wǎng)頁
192.168.109.137 192.168.109.134另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)cdcxhl.cn,海內(nèi)外云服務(wù)器15元起步,三天無理由+7*72小時(shí)售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務(wù)可用性高、性價(jià)比高”等特點(diǎn)與優(yōu)勢(shì),專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場景需求。