欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

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

 更新時間:2019年11月13日 09:13:13   作者:wx5d3fd1efe40e3  
本文給大家分享基于域名、端口和IP搭建nginx虛擬主機的內容,非常不錯,具有一定的參考借鑒價值,需要的朋友參考下吧

nginx支持的虛擬主機有三種

1、基于域名的虛擬主機

2、基于IP的虛擬主機

3、基于端口的虛擬主機

一、基于域名構建

1、編譯安裝nginx服務

2、配置DNS域名解析服務

3、配置虛擬主機

a、創(chuà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、重載服務

systemctl restart nginx
netstat -ntap | grep 80

d、訪問測試

www.kgc.com
www.accp.com

二、基于端口

a、創(chuà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服務

systemctl restart nginx
netstat -ntap | grep 80

d、測試網頁

www.accp.com
www.accp.com8080

三、基于IP

1、修改網頁配置文件中的區(qū)域數據配置文件

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服務

systemctl restart nginx
netstat -ntap | grep 80

d、測試網頁

192.168.109.137
192.168.109.134

總結

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

相關文章

  • Logrotate如何實現每小時切割日志文件

    Logrotate如何實現每小時切割日志文件

    這篇文章主要介紹了Logrotate如何實現每小時切割日志文件問題,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2023-05-05
  • 為什么 Nginx 比 Apache 更牛

    為什么 Nginx 比 Apache 更牛

    為什么Nginx在處理高并發(fā)方面要優(yōu)于httpd,我們先從兩種web服務器的工作原理以及工作模式說起。對Nginx對比 Apache的相關知識感興趣的朋友跟隨小編一起看看吧
    2021-02-02
  • Apache和Nginx的優(yōu)缺點詳解_動力節(jié)點Java學院整理

    Apache和Nginx的優(yōu)缺點詳解_動力節(jié)點Java學院整理

    Nginx和Apache一樣,都是HTTP服務器軟件,在功能實現上都采用模塊化結構設計,都支持通用的語言接口。下面通過本文給大家分享Apache和Nginx比較 功能對比,感興趣的朋友參考下吧
    2017-08-08
  • Nginx中upstream模塊的具體用法

    Nginx中upstream模塊的具體用法

    本文主要介紹了Nginx中upstream模塊的具體用法,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧
    2023-04-04
  • 解讀nginx負載均衡的5種策略

    解讀nginx負載均衡的5種策略

    這篇文章主要介紹了解讀nginx負載均衡的5種策略,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2023-07-07
  • Nginx上配置Basic Authorization登錄認服務證的教程

    Nginx上配置Basic Authorization登錄認服務證的教程

    現在我們所使用的包括社交網絡API等開放平臺授權獲得用戶的用戶名和密碼一般有兩種認證方式,一種是Basic Auth,一種是OAuth,這里我們就來看一下Nginx上配置Basic Authorization登錄認服務證的教程
    2016-06-06
  • nginx+tomcat實現Windows系統(tǒng)下的負載均衡搭建教程

    nginx+tomcat實現Windows系統(tǒng)下的負載均衡搭建教程

    下面小編就為大家分享一篇nginx+tomcat實現Windows系統(tǒng)下的負載均衡搭建教程,具有很好的參考價值,希望對大家有所幫助
    2017-12-12
  • nginx 網頁匹配跳轉rewrite、location的具體使用

    nginx 網頁匹配跳轉rewrite、location的具體使用

    本文主要介紹了nginx 網頁匹配跳轉rewrite、location的具體使用
    2024-05-05
  • Linux平臺通過nginx和vsftpd構建圖片服務器

    Linux平臺通過nginx和vsftpd構建圖片服務器

    這篇文章主要介紹了Linux平臺通過nginx和vsftpd構建圖片服務器,需要的朋友可以參考下
    2017-05-05
  • Nginx配置二級域名的方法實現

    Nginx配置二級域名的方法實現

    本文主要介紹了Nginx配置二級域名的方法實現,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧
    2023-03-03

最新評論