五月综合激情婷婷六月,日韩欧美国产一区不卡,他扒开我内裤强吻我下面视频 ,无套内射无矿码免费看黄,天天躁,日日躁,狠狠躁

新聞動(dòng)態(tài)

nginx基于域名,端口,不同IP的虛擬主機(jī)設(shè)置的實(shí)現(xiàn)

發(fā)布日期:2022-01-09 12:54 | 文章來源:CSDN

一. nginx 虛擬主機(jī)的設(shè)置

利用虛擬主機(jī),不用為每個(gè)要運(yùn)行的網(wǎng)站提供一臺(tái)單獨(dú)的Nginx服務(wù)器或單獨(dú)運(yùn)行一組Nginx進(jìn)程,虛擬主機(jī)提供了在同一臺(tái)服務(wù)器,同一組 Nginx進(jìn)程上運(yùn)行多個(gè)網(wǎng)站的功能。跟Apache一樣,Nginx也可以配置多種類型的虛擬主機(jī),分別是基于IP的虛擬主機(jī)、基于域名的虛擬主機(jī)、基于端口的虛擬主機(jī)。
使用Nginx搭建虛擬主機(jī)服務(wù)器時(shí),每個(gè)虛擬Web站點(diǎn)擁有獨(dú)立的“serverf”配置段,各自監(jiān)聽的IP地址、端口號(hào)可以單獨(dú)指定,當(dāng)然網(wǎng)站名稱也是不同的。

1.1 基于域名的虛擬主機(jī)

1.11 改測試系統(tǒng)的WIN10的映射文件host

1)修改host文件

修改windos客戶機(jī)的C:\Windows\System32\drivers\etc\hosts文件,加入www.51xit.top和www.52xit.top這兩個(gè)域名,它們都指向同一個(gè)服務(wù)器IP地址,用于實(shí)現(xiàn)不同的域名訪問不同的虛擬主機(jī)。

20.0.0.24 www.lph.com www.dzg.com

2)開啟nginx服務(wù)對(duì)域名進(jìn)行初測試

無論是測試www.lph.com 還是www.dzg.com都是指向的服務(wù)器20.0.0.24的網(wǎng)站測試首頁。

瀏覽器中訪問:www.lph.com

瀏覽器中訪問:www.dzg.com


后面要實(shí)現(xiàn)的是訪問不同的域名可以訪問到不同的網(wǎng)點(diǎn)。

1.12 各個(gè)網(wǎng)站的目錄和測試首頁

[root@localhost~]# mkdir -p /var/www/html/lph/       ####創(chuàng)建www.lph.com的根目錄
[root@localhost~]# mkdir -p /var/www/html/dzg/       ####創(chuàng)建www.dzg.com的根目錄
[root@localhost~]# echo "www.lph.com" >> /var/www/html/lph/index.html
[root@localhost~]# echo "www.dzg.com" >> /var/www/html/dzg/index.html

1.13 主配置文件

修改配置文件/usr/local/nginx/conf/nginx.conf,把配置文件中的server{}代碼段全部去掉,加入2個(gè)新的server{}段,對(duì)應(yīng)2個(gè)域名。

1)配置文件的修改

####省略####
  server {
    listen    80;
    server_name www.lph.com;
    charset utf-8;
    access_log logs/www.lph.com.access.log;
    location / {
      root  /var/www/html/lph;
      index index.html index.htm;
    }
    error_page  500 502 503 504 /50x.html;
    location = /50x.html {
      root  html;
    }
  }
    server {
    listen    80;
    server_name www.dzg.com;
    charset utf-8;
    access_log logs/www.dzg.com.access.log;
    location / {
      root  /var/www/html/dzg;
      index index.html index.htm;
    }
    error_page  500 502 503 504 /50x.html;
    location = /50x.html {
      root  html;
    }
  }
  ####省略####

2)客戶機(jī)測試
訪問www.lph.com


訪問www.dzg.com

1.2 基于端口的虛擬主機(jī)

只需要一個(gè)IP地址的不同端口實(shí)現(xiàn)訪問不同的網(wǎng)點(diǎn)

1.21 配置文件的修改

server {
  listen   20.0.0.24:80;
  server_name www.lph.com;
  charset utf-8;
  access_log logs/www.lph.com.access.log;
  location / {
    root  /var/www/html/lph;
    index index.html index.htm;
  }
  error_page  500 502 503 504 /50x.html;
  location = /50x.html {
    root  html;
  }
}
server {
  listen    20.0.0.24:8080;
  server_name www.dzg.com;
  charset utf-8;
  access_log logs/www.dzg8080.com.access.log;
  location / {
    root  /var/www/html/dzg;
    index index.html index.htm;
  }
  error_page  500 502 503 504 /50x.html;
  location = /50x.html {
    root  html;
  }
}

1.22 客戶機(jī)的測試

訪問www.lph.com:80和訪問20.0.0.24:80


訪問www.dzg.com:8080及訪問20.0.0.24:8080

1.3 基于不同IP的虛擬主機(jī)

主機(jī)配置兩個(gè)IP地址
20.0.0.24 192.168.100.24

1.31 添加一張網(wǎng)卡并設(shè)置IP

[root@localhost ~]# nmcli connection    #復(fù)制新增網(wǎng)卡的地址
[root@localhost ~]# cd /etc/sysconfig/network-scripts/
[root@localhost network-scripts]# cp ifcfg-ens33 ifcfg-ens36
[root@localhost network-scripts]# vi ifcfg-ens36
NAME=ens36
UUID=ee2dccf4-cc4a-34bc-9cea-37e7d528cd27   #粘貼新增網(wǎng)卡的地址
DEVICE=ens36
ONBOOT=yes
IPADDR=192.168.100.26
NETMASK=255.255.255.0
GATEWAY=192.168.100.1
[root@localhost ~]# systemctl restart network
[root@localhost ~]# ifdown ens36
[root@localhost ~]# ifup ens36
#######打開電腦cmd ping一下   ping通繼續(xù)

1.32 修改客戶機(jī)的host 文件

20.0.0.0.24 www.lph.com
192.168.100.24 www.dzg.com

1.33 修改配置文件

server {
  listen   20.0.0.24:80;
  server_name www.lph.com;
  charset utf-8;
  access_log logs/www.lph.com.access.log;
  location / {
    root  /var/www/html/lph;
    index index.html index.htm;
  }
  error_page  500 502 503 504 /50x.html;
  location = /50x.html {
    root  html;
  }
}
server {
  listen    192.168.100.24:80;
  server_name www.dzg.com;
  charset utf-8;
  access_log logs/www.dzg.com.access.log;
  location / {
    root  /var/www/html/dzg;
    index index.html index.htm;
  }
  error_page  500 502 503 504 /50x.html;
  location = /50x.html {
    root  html;
  }
}

1.34 客戶機(jī)測試

訪問www.lph.com和訪問20.0.0.24


訪問www.dzg.com和訪問192.168.100.24

到此這篇關(guān)于nginx基于域名,端口,不同IP的虛擬主機(jī)設(shè)置的實(shí)現(xiàn)的文章就介紹到這了,更多相關(guān)nginx 虛擬主機(jī)設(shè)置內(nèi)容請(qǐng)搜索本站以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持本站!

版權(quán)聲明:本站文章來源標(biāo)注為YINGSOO的內(nèi)容版權(quán)均為本站所有,歡迎引用、轉(zhuǎn)載,請(qǐng)保持原文完整并注明來源及原文鏈接。禁止復(fù)制或仿造本網(wǎng)站,禁止在非maisonbaluchon.cn所屬的服務(wù)器上建立鏡像,否則將依法追究法律責(zé)任。本站部分內(nèi)容來源于網(wǎng)友推薦、互聯(lián)網(wǎng)收集整理而來,僅供學(xué)習(xí)參考,不代表本站立場,如有內(nèi)容涉嫌侵權(quán),請(qǐng)聯(lián)系alex-e#qq.com處理。

實(shí)時(shí)開通

自選配置、實(shí)時(shí)開通

免備案

全球線路精選!

全天候客戶服務(wù)

7x24全年不間斷在線

專屬顧問服務(wù)

1對(duì)1客戶咨詢顧問

在線
客服

在線客服:7*24小時(shí)在線

客服
熱線

400-630-3752
7*24小時(shí)客服服務(wù)熱線

關(guān)注
微信

關(guān)注官方微信
頂部