欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

Nginx服務(wù)虛擬主機(jī)的配置----------基于域名、端口、IP(實戰(zhàn)!)

DNS服務(wù)配置

1.安裝bind服務(wù)

[root@localhost sbin]# yum install bind -y
...........//省略安裝過程
[root@localhost sbin]#

2.查看網(wǎng)卡信息(IP地址)

[root@localhost named]# ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.52.133  netmask 255.255.255.0  broadcast 192.168.52.255
        inet6 fe80::3e1d:31ba:f66a:6f80  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:27:1c:3f  txqueuelen 1000  (Ethernet)
        RX packets 384057  bytes 558603083 (532.7 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 182891  bytes 11237471 (10.7 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

3.修改主配置文件

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

options {
        listen-on port 53 { any; };    //127.0.0.1改為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; };      //localhost改為any

[root@localhost sbin]#

4.修改區(qū)域配置文件

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

zone "abc.com" IN {        //添加兩個區(qū)域信息
        type master;
        file "abc.com.zone";
        allow-update { none; };
};

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

[root@localhost sbin]#

5.修改區(qū)域數(shù)據(jù)配置文件

[root@localhost sbin]# cd /var/named/
[root@localhost named]# ls
data  dynamic  named.ca  named.empty  named.localhost  named.loopback  slaves
[root@localhost named]# cp -p named.localhost abc.com.zone    //復(fù)制模板并命名
[root@localhost named]# vim abc.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.52.133   //添加解析地址

[root@localhost named]# cp -p abc.com.zone xyz.com.zone    //復(fù)制abc域名的區(qū)域配置文件命名為xyz域名
[root@localhost named]# ls
abc.com.zone  data  dynamic  named.ca  named.empty  named.localhost  named.loopback  slaves  xyz.com.zone
[root@localhost named]# 
[root@localhost named]# systemctl start named   //開啟dns服務(wù)
[root@localhost named]# systemctl stop firewalld.service    //關(guān)閉防火墻
[root@localhost named]# setenforce 0    //關(guān)閉增強(qiáng)性安全功能
[root@localhost named]# 

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

1.分別給兩個站點創(chuàng)建首頁文件

[root@localhost named]# mkdir -p /var/www/html/abc    //創(chuàng)建abc站點
[root@localhost named]# mkdir -p /var/www/html/xyz    //創(chuàng)建xyz站點
[root@localhost named]# cd /var/www/html/
[root@localhost html]# ls
abc  xyz
[root@localhost html]# echo "this is abc web" > abc/index.html   //創(chuàng)建首頁文件
[root@localhost html]# echo "this is xyz web" > xyz/index.html   //創(chuàng)建首頁文件
[root@localhost html]#

2.修改nginx服務(wù)配置文件

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

    server {
        listen       80;             //監(jiān)聽端口
        server_name  www.abc.com;      //域名
        charset utf-8;      //字符集,utf-8支持中文字符
        access_log  logs/www.abc.com.access.log;     //訪問日志
        location / {
            root   /var/www/html/abc;    //站點
            index  index.html index.htm;     //支持的首頁類型
        }
        error_page   500 502 503 504  /50x.html;    //訪問錯誤文件
        location = /50x.html {
            root   html;     //站點
        }
    }

    server {
        listen       80;    //監(jiān)聽端口
        server_name  www.xyz.com;     //域名
        charset utf-8;      //字符集,utf-8支持中文字符
        access_log  logs/www.xyz.com.access.log;    //訪問日志
        location / { 
            root   /var/www/html/xyz;    //站點
            index  index.html index.htm;     //支持的首頁類型
        }
        error_page   500 502 503 504  /50x.html;    //訪問錯誤文件
        location = /50x.html {
            root   html;     //站點
        }
    } 

[root@localhost html]#

3.檢查測試配置文件,并重啟服務(wù)

[root@localhost html]# 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 html]# service nginx restart      //重啟服務(wù)
[root@localhost html]# 

4.開啟一臺win10作為測試機(jī),設(shè)置dns地址

Nginx服務(wù)虛擬主機(jī)的配置----------基于域名、端口、IP(實戰(zhàn)!)

創(chuàng)新互聯(lián)專注骨干網(wǎng)絡(luò)服務(wù)器租用十年,服務(wù)更有保障!服務(wù)器租用,中國電信云錦天府 成都服務(wù)器租用,成都服務(wù)器托管,骨干網(wǎng)絡(luò)帶寬,享受低延遲,高速訪問。靈活、實現(xiàn)低成本的共享或公網(wǎng)數(shù)據(jù)中心高速帶寬的專屬高性能服務(wù)器。

5.測試能否進(jìn)行域名解析(成功)

Nginx服務(wù)虛擬主機(jī)的配置----------基于域名、端口、IP(實戰(zhàn)!)

6.用測試機(jī)瀏覽器訪問兩個域名

Nginx服務(wù)虛擬主機(jī)的配置----------基于域名、端口、IP(實戰(zhàn)!)

Nginx服務(wù)虛擬主機(jī)的配置----------基于域名、端口、IP(實戰(zhàn)!)

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

1.修改nginx服務(wù)的配置文件

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

    server {
        listen       192.168.52.133:80;     //監(jiān)聽端口
        server_name  www.abc.com;
        charset utf-8;
        access_log  logs/www.abc.com.access.log;    //訪問日志
        location / {
            root   /var/www/html/abc;     //站點
            index  index.html index.htm;
        }
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }

    server {
        listen       192.168.52.133:8080;    //監(jiān)聽端口
        server_name  www.abc.com;
        charset utf-8;
        access_log  logs/www.abc8080.com.access.log;     //訪問日志
        location / {
            root   /var/www/html/abc8080;     //站點
            index  index.html index.htm;
        }
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }

2.測試配置文件

[root@localhost html]# 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 html]# 

3.創(chuàng)建8080端口站點目錄與首頁文件

[root@localhost html]# mkdir abc8080   //創(chuàng)建站點目錄
[root@localhost html]# echo "this is abc8080 web" > abc8080/index.html     //創(chuàng)建首頁文件
[root@localhost html]# service nginx restart    //重啟nginx服務(wù)
[root@localhost html]#

4.用測試機(jī)瀏覽器訪問相同域名的不同端口

Nginx服務(wù)虛擬主機(jī)的配置----------基于域名、端口、IP(實戰(zhàn)!)

Nginx服務(wù)虛擬主機(jī)的配置----------基于域名、端口、IP(實戰(zhàn)!)

基于IP的虛擬主機(jī)配置

1.給虛擬機(jī)添加一塊網(wǎng)卡

Nginx服務(wù)虛擬主機(jī)的配置----------基于域名、端口、IP(實戰(zhàn)!)

2.查看網(wǎng)卡信息(IP地址)

[root@localhost html]# ifconfig 
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.52.133  netmask 255.255.255.0  broadcast 192.168.52.255
        inet6 fe80::3e1d:31ba:f66a:6f80  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:27:1c:3f  txqueuelen 1000  (Ethernet)
        RX packets 391887  bytes 559453355 (533.5 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 185573  bytes 11520948 (10.9 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

ens36: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.52.139  netmask 255.255.255.0  broadcast 192.168.52.255
        inet6 fe80::f7fb:4ddc:f4b6:b90a  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:27:1c:49  txqueuelen 1000  (Ethernet)
        RX packets 14  bytes 1737 (1.6 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 24  bytes 4219 (4.1 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

3.修改域名區(qū)域數(shù)據(jù)配置文件“xyz.com.zone”的解析地址

[root@localhost html]# vim /var/named/xyz.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.52.139    //修改ip地址為192.168.52.139

[root@localhost html]# systemctl restart named    //重啟dns服務(wù)
[root@localhost html]# 

4.用測試機(jī)檢查域名解析是否正常(正常)

Nginx服務(wù)虛擬主機(jī)的配置----------基于域名、端口、IP(實戰(zhàn)!)

5.修改nginx服務(wù)的配置文件

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

    server {
        listen       192.168.52.133:80;     //監(jiān)聽IP地址與端口
        server_name  www.abc.com;    //域名
        charset utf-8;    //字符集,utf-8支持中文字符
        access_log  logs/www.abc.com.access.log;    //訪問日志
        location / { 
            root   /var/www/html/abc;    //站點
            index  index.html index.htm;   //支持的首頁格式
        }
        error_page   500 502 503 504  /50x.html;    //訪問錯誤首頁文件
        location = /50x.html {
            root   html;      //站點
        }
    } 

    server {
        listen       192.168.52.139:80;     //監(jiān)聽IP地址與端口
        server_name  www.xyz.com;    //域名
        charset utf-8;    //字符集,utf-8支持中文字符
        access_log  logs/www.xyz.com.access.log;    //訪問日志
        location / {
            root   /var/www/html/xyz;    //站點
            index  index.html index.htm;   //支持的首頁格式
        }
        error_page   500 502 503 504  /50x.html;    //訪問錯誤首頁文件
        location = /50x.html {
            root   html;      //站點
        }
    }

6.測試配置文件,沒有問題,重啟服務(wù)

[root@localhost html]# 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 html]# service nginx restart    //重啟服務(wù)
[root@localhost html]# 

7.用測試機(jī)分別訪問兩個不同IP地址的域名

Nginx服務(wù)虛擬主機(jī)的配置----------基于域名、端口、IP(實戰(zhàn)!)

Nginx服務(wù)虛擬主機(jī)的配置----------基于域名、端口、IP(實戰(zhàn)!)

本文標(biāo)題:Nginx服務(wù)虛擬主機(jī)的配置----------基于域名、端口、IP(實戰(zhàn)!)
網(wǎng)頁鏈接:http://www.chinadenli.net/article30/ieogso.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供外貿(mào)建站網(wǎng)站導(dǎo)航響應(yīng)式網(wǎng)站企業(yè)建站網(wǎng)站內(nèi)鏈小程序開發(fā)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

外貿(mào)網(wǎng)站制作