日本综合一区二区|亚洲中文天堂综合|日韩欧美自拍一区|男女精品天堂一区|欧美自拍第6页亚洲成人精品一区|亚洲黄色天堂一区二区成人|超碰91偷拍第一页|日韩av夜夜嗨中文字幕|久久蜜综合视频官网|精美人妻一区二区三区

RELATEED CONSULTING
相關(guān)咨詢(xún)
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時(shí)間:8:30-17:00
你可能遇到了下面的問(wèn)題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營(yíng)銷(xiāo)解決方案
Nginx虛擬主機(jī)之域名,端口,IP

Nginx虛擬主機(jī)之域名,端口,IP

創(chuàng)新互聯(lián)公司是專(zhuān)業(yè)的臨夏網(wǎng)站建設(shè)公司,臨夏接單;提供網(wǎng)站設(shè)計(jì)制作、做網(wǎng)站,網(wǎng)頁(yè)設(shè)計(jì),網(wǎng)站設(shè)計(jì),建網(wǎng)站,PHP網(wǎng)站建設(shè)等專(zhuān)業(yè)做網(wǎng)站服務(wù);采用PHP框架,可快速的進(jìn)行臨夏網(wǎng)站開(kāi)發(fā)網(wǎng)頁(yè)制作和功能擴(kuò)展;專(zhuān)業(yè)做搜索引擎喜愛(ài)的網(wǎng)站,專(zhuān)業(yè)的做網(wǎng)站團(tuán)隊(duì),希望更多企業(yè)前來(lái)合作!

要nginx源碼包請(qǐng)私信我

Nginx虛擬主機(jī)之域名

[root@localhost ~]# yum install bind -y

配置DNS主配置文件

[root@localhost ~]# vim /etc/named.conf 

options {
        listen-on port 53 { any; };
        listen-on-v6 port 53 { ::1; };
        directory       "/var/named";
        dump-file       "/var/named/data/cache_dump.db";
        statistics-file "/var/named/data/named_stats.txt";
        memstatistics-file "/var/named/data/named_mem_stats.txt";
        recursing-file  "/var/named/data/named.recursing";
        secroots-file   "/var/named/data/named.secroots";
        allow-query     { any; };

配置區(qū)域配置文件

[root@localhost ~]# vim /etc/named.rfc1912.zones 

zone "cwq.com" IN {
        type master;
        file "cwq.com.zone";
        allow-update { none; };
};
zone "kgc.com" IN {        
        type master;
        file "kgc.com.zone";
        allow-update { none; };
};

zone "1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.

配置區(qū)域數(shù)據(jù)配置文件

[root@localhost ~]# cd /var/named/
[root@localhost named]# cp -p named.localhost cwq.com.zone
[root@localhost named]# vim cwq.com.zone 
$TTL 1D
@       IN SOA  @ rname.invalid. (
                                        0       ; serial
                                        1D      ; refresh
                                        1H      ; retry
                                        1W      ; expire
                                        3H )    ; minimum
        NS      @
        A       127.0.0.1
www IN  A       192.168.136.162

[root@localhost named]# cp -p cwq.com.zone kgc.com.zone 

開(kāi)啟DNS服務(wù)

[root@localhost named]# systemctl start named
[root@localhost named]# systemctl stop firewalld.service 
[root@localhost named]# setenforce 0

去win10去測(cè)試一下能不能解析域名

Nginx虛擬主機(jī)之域名,端口,IP

安裝nginx環(huán)境包

[root@localhost named]# yum install gcc gcc-c++ pcre-devel zlib-devel -y

[root@localhost named]# mkdir /abc
[root@localhost named]# mount.cifs //192.168.100.23/LNMP /abc
Password for root@//192.168.100.23/LNMP:  
[root@localhost named]# cd /abc/
[root@localhost abc]# ls
MySQL-boost-5.7.20.tar.gz  nginx-1.12.2.tar.gz  php-7.1.20.tar.gz
nginx-1.12.0.tar.gz        php-7.1.10.tar.bz2
[root@localhost abc]# tar zxvf nginx-1.12.2.tar.gz -C /opt/

編譯安裝

[root@localhost abc]# cd /opt/
[root@localhost opt]# cd nginx-1.12.2/
[root@localhost nginx-1.12.2]# useradd -M -s /sbin/nologin nginx  #創(chuàng)建程序性用戶(hù)去管理,-M沒(méi)有家目錄,-s不登錄本地控制臺(tái)
./configure \
--prefix=/usr/local/nginx \  #指定路徑
--user=nginx \  #指定用戶(hù)
--group=nginx \  #指定組
--with-http_stub_status_module #狀態(tài)統(tǒng)計(jì)模塊

[root@localhost nginx-1.12.2]# make
[root@localhost nginx-1.12.2]# make install

在它編譯的時(shí)候我們?cè)匍_(kāi)一臺(tái)終端去創(chuàng)建站點(diǎn)網(wǎng)頁(yè)

[root@localhost ~]# mkdir -p /var/www/html/cwq
[root@localhost ~]# mkdir -p /var/www/html/kgc
[root@localhost ~]# cd /var/www/html/
[root@localhost html]# ls
cwq  kgc
[root@localhost html]# echo "this is cwq web" > cwq/index.html
[root@localhost html]# echo "this is kgc web" > kgc/index.html
[root@localhost html]# ls cwq/
index.html
[root@localhost html]# ls kgc/
index.html

做軟鏈接,測(cè)試語(yǔ)法

[root@localhost nginx-1.12.2]# ln -s /usr/local/nginx/sbin/nginx /usr/local/sbin/
[root@localhost nginx-1.12.2]# nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful

寫(xiě)nginx腳本放在系統(tǒng)啟動(dòng)腳本中方便service管理器管理

[root@localhost nginx-1.12.2]# cd /etc/init.d/

[root@localhost init.d]# vim nginx  

#!/bin/bash
#chkconfig: - 99 20  #注釋信息
#description: Nginx Service Control Script
PROG="/usr/local/nginx/sbin/nginx"  #這個(gè)變量,指向我的命令文件
PIDF="/usr/local/nginx/logs/nginx.pid"  #這個(gè)變量,指向nginx的進(jìn)程號(hào)
case "$1" in
    start)
        $PROG                                              
        ;;
    stop)
        kill -s QUIT $(cat $PIDF) 
        ;;
    restart)                                                  
        $0 stop
        $0 start
        ;;
    reload)                                                  
        kill -s HUP $(cat $PIDF)
        ;;
    *)                                                           
                echo "Usage: $0 {start|stop|restart|reload}"
                exit 1
esac
exit 0

[root@localhost init.d]# chmod +x nginx  #添加執(zhí)行權(quán)限
[root@localhost init.d]# chkconfig --add nginx #添加nginx
[root@localhost init.d]# service nginx start 
[root@localhost init.d]# netstat -ntap | grep nginx  #查看nginx端口有沒(méi)有被提供出來(lái)
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LIST
EN      42982/nginx: master

再用win10測(cè)試一下,我們需要的是不同的域名訪問(wèn)不同的網(wǎng)頁(yè)

Nginx虛擬主機(jī)之域名,端口,IPNginx虛擬主機(jī)之域名,端口,IP

編輯nginx配置文件

[root@localhost init.d]# cd /usr/local/nginx/conf/
[root@localhost conf]# vim nginx.conf

#sever區(qū)域中其他多余的全刪掉
server {
         listen       80;
 33         server_name  www.cwq.com;  #域名
 34         charset utf-8;  #識(shí)別中文字符集
 35         access_log  logs/www.cwq.com.access.log; #域名日志文件
 36         location / {
 37             root   /var/www/html/cwq;  #指定站點(diǎn)
 38             index  index.html index.htm;
 39         }   
 40         error_page   500 502 503 504  /50x.html;
 41         location = /50x.html {
 42             root   html;
 43         }   
 44     }   
 45     
 46     
47     server {
 48         listen       80;
 49         server_name  www.kgc.com;
 50         charset utf-8;
 51         access_log  logs/www.kgc.com.access.log;
 52         location / {
 53             root   /var/www/html/kgc;
 54             index  index.html index.htm;
 55         }
 56         error_page   500 502 503 504  /50x.html;
 57         location = /50x.html {
 58             root   html;
 59         }
 60     }
 61     # another virtual host using mix of IP-, name-, and port-based c    onfiguration
#多余的內(nèi)容一直刪到這個(gè)地方

檢查語(yǔ)法,重啟服務(wù)

[root@localhost conf]# nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
[root@localhost conf]# service nginx restart

去win10再測(cè)試一下

Nginx虛擬主機(jī)之域名,端口,IP
Nginx虛擬主機(jī)之域名,端口,IP

Nginx虛擬主機(jī)之基于端口

給8080端口寫(xiě)一個(gè)網(wǎng)頁(yè)

[root@localhost conf]# cd /var/www/html/
[root@localhost html]# mkdir kgc8080
[root@localhost html]# echo "this is kgc8080 web" > kgc8080/index.html

配置nginx文件

[root@localhost html]# cd /usr/local/nginx/conf/

#先把我們之前的cwq域名的注釋掉,31,44 s/^/#/g,不然就和下面的地址沖突了
31 #    server {
  #        listen       80;
 33 #        server_name  www.cwq.com;
 34 #        charset utf-8;
 35 #        access_log  logs/www.cwq.com.access.log;
 36 #        location / {
 37 #            root   /var/www/html/cwq;
 38 #            index  index.html index.htm;
 39 #        }  
 40 #        error_page   500 502 503 504  /50x.html;
 41 #        location = /50x.html {
 42 #            root   html;
 43 #        }  
 44 #    }  

46     server {
 47         listen       192.168.136.162:80;
 48         server_name  www.kgc.com;
 49         charset utf-8;
 50         access_log  logs/www.kgc.com.access.log;
 51         location / {
 52             root   /var/www/html/kgc;
 53             index  index.html index.htm;
 54         }   
 55         error_page   500 502 503 504  /50x.html;
 56         location = /50x.html {
 57             root   html;
 58         }   
 59     }   
 60  
 61     server {
 62         listen       192.168.136.162:8080;
 63         server_name  www.kgc.com;
 64         charset utf-8;
 65         access_log  logs/www.kgc8080.com.access.log;  #不同端口的日志文件
 66         location / {
 67             root   /var/www/html/kgc8080;  #不同端口的站點(diǎn)
 68             index  index.html index.htm;
 69         }
 70         error_page   500 502 503 504  /50x.html;
 71         location = /50x.html {
 72             root   html;
 73         }
 74     }

檢查語(yǔ)法,重啟服務(wù),查看兩個(gè)端口有沒(méi)有被提供出來(lái)

[root@localhost conf]# nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
[root@localhost conf]# service nginx restart
[root@localhost conf]# netstat -ntap | grep nginx
tcp        0      0 192.168.136.162:8080    0.0.0.0:*               LISTEN      43616/nginx: master 
tcp        0      0 192.168.136.162:80      0.0.0.0:*               LISTEN      43616/nginx: master 

去win10測(cè)試一下

Nginx虛擬主機(jī)之域名,端口,IP

這是我第二塊網(wǎng)卡的網(wǎng)址

Nginx虛擬主機(jī)之基于IP地址

我們先給服務(wù)器添加一塊網(wǎng)卡

Nginx虛擬主機(jī)之域名,端口,IP

這是我第二塊網(wǎng)卡的網(wǎng)址

ens36: flags=4163  mtu 1500
        inet 192.168.136.171  netmask 255.255.255.0  broadcast 192.168.136.255

kgc區(qū)域數(shù)據(jù)配置文件改個(gè)地址就行

[root@localhost ~]# cd /var/named/
[root@localhost named]# vim kgc.com.zone 

$TTL 1D
@       IN SOA  @ rname.invalid. (
                                        0       ; serial
                                        1D      ; refresh
                                        1H      ; retry
                                        1W      ; expire
                                        3H )    ; minimum
        NS      @
        A       127.0.0.1
www IN  A       192.168.136.171

[root@localhost named]# systemctl restart named

用win10測(cè)試能不能解析域名成功

Nginx虛擬主機(jī)之域名,端口,IP

配置nginx配置文件

[root@localhost named]# cd /usr/local/nginx/conf/
[root@localhost conf]# vim nginx.conf
#把之前端口的注釋掉,61,74 s/^/#/g
 61 #    server {
 62 #        listen       192.168.136.162:8080;
 63 #        server_name  www.kgc.com;
 64 #        charset utf-8;
 65 #        access_log  logs/www.kgc8080.com.access.log;
 66 #        location / {
 67 #            root   /var/www/html/kgc8080;
 68 #            index  index.html index.htm;
 69 #        }
 70 #        error_page   500 502 503 504  /50x.html;
 71 #        location = /50x.html {
 72 #            root   html;
 73 #        }
 74 #    }
#把前面的注釋去掉,31,44 s/#//g
31     server {
        listen       192.168.136.162:80;
 33         server_name  www.cwq.com;
 34         charset utf-8;
 35         access_log  logs/www.cwq.com.access.log;
 36         location / {
 37             root   /var/www/html/cwq;
 38             index  index.html index.htm;
 39         }
 40         error_page   500 502 503 504  /50x.html;
 41         location = /50x.html {
 42             root   html;
 43         }
 44     }
#kgc的區(qū)域監(jiān)聽(tīng)地址換成第二塊網(wǎng)卡的地址
 47         listen       192.168.136.171:80;

檢查語(yǔ)法,重啟服務(wù)

[root@localhost conf]# nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
[root@localhost conf]# service nginx restart 

再去win10測(cè)試一下是不是不同的網(wǎng)址(域名)獲得同一個(gè)網(wǎng)頁(yè)

Nginx虛擬主機(jī)之域名,端口,IP
Nginx虛擬主機(jī)之域名,端口,IP

以上就是我們所有的內(nèi)容了,謝謝收看


本文名稱(chēng):Nginx虛擬主機(jī)之域名,端口,IP
網(wǎng)站鏈接:http://www.dlmjj.cn/article/jishhd.html