婷婷综合国产,91蜜桃婷婷狠狠久久综合9色 ,九九九九九精品,国产综合av

主頁 > 知識庫 > 基于域名、端口和IP搭建nginx虛擬主機

基于域名、端口和IP搭建nginx虛擬主機

熱門標(biāo)簽:江西外呼系統(tǒng) 湖北ai智能電銷機器人 AI電銷機器人 源碼 高德地圖標(biāo)注論壇 北海市地圖標(biāo)注app 新邵電銷機器人企業(yè) 蘭州ai電銷機器人招商 新科美甲店地圖標(biāo)注 外呼系統(tǒng)打哪顯哪

nginx支持的虛擬主機有三種

1、基于域名的虛擬主機

2、基于IP的虛擬主機

3、基于端口的虛擬主機

一、基于域名構(gòu)建

1、編譯安裝nginx服務(wù)

2、配置DNS域名解析服務(wù)

3、配置虛擬主機

a、創(chuàng)建自測網(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 80

d、訪問測試

www.kgc.com
www.accp.com

二、基于端口

a、創(chuàng)建另一個端口的測試網(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 80

d、測試網(wǎng)頁

www.accp.com
www.accp.com8080

三、基于IP

1、修改網(wǎng)頁配置文件中的區(qū)域數(shù)據(jù)配置文件

vim /var/named/kgc.com.zone
systemctl restart named

2、編輯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 80

d、測試網(wǎng)頁

192.168.109.137
192.168.109.134

總結(jié)

以上所述是小編給大家介紹的基于域名、端口和IP搭建nginx虛擬主機,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復(fù)大家的。在此也非常感謝大家對腳本之家網(wǎng)站的支持!
如果你覺得本文對你有幫助,歡迎轉(zhuǎn)載,煩請注明出處,謝謝!

標(biāo)簽:池州 海南 黔東 自貢 黃石 阿克蘇 大理 南陽

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《基于域名、端口和IP搭建nginx虛擬主機》,本文關(guān)鍵詞  基于,域名,端口,和,搭建,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《基于域名、端口和IP搭建nginx虛擬主機》相關(guān)的同類信息!
  • 本頁收集關(guān)于基于域名、端口和IP搭建nginx虛擬主機的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章
    主站蜘蛛池模板: 郓城县| 永宁县| 阿尔山市| 浠水县| 古蔺县| 平谷区| 泸西县| 奉化市| 沂南县| 岳普湖县| 万山特区| 宣城市| 大石桥市| 临澧县| 水城县| 大名县| 旌德县| 晋宁县| 公主岭市| 台东县| 灵石县| 绥芬河市| 韶山市| 丹东市| 清新县| 巴中市| 时尚| 白沙| 乌什县| 徐水县| 个旧市| 宣化县| 麟游县| 千阳县| 高密市| 明星| 元氏县| 安溪县| 西平县| 乐昌市| 噶尔县|