玩家必看科普!麻豆人人妻人人妻人人片AV,欧美老妇交乱视频在线观看,久久综合九色综合久99_知乎
<ruby id="fgcka"></ruby>
  • <progress id="fgcka"></progress>
    <tbody id="fgcka"></tbody>
    <dd id="fgcka"></dd>

    1. <dd id="fgcka"></dd>

      <em id="fgcka"></em>
        1. 系統城裝機大師 - 固鎮縣祥瑞電腦科技銷售部宣傳站!

          當前位置:首頁 > server > anz > 詳細頁面

          Nginx主機域名配置實現

          時間:2023-03-17來源:系統城裝機大師作者:佚名

          一、配置多個端口訪問不同文件

          相同域名,不同端口,不同文件

          1
          2
          3
          4
          5
          6
          7
          #兩個不同文件夾,分別存放不同文件
          [root@nginx ~]# mkdir /www/work_01 -p
          [root@nginx ~]# mkdir /www/work_02
          [root@nginx ~]# vim /www/work_01/index.html
          this is work_01!
          [root@nginx ~]# vim /www/work_02/index.html
          this is work_02!

          #編輯其中server模塊,把端口80的站點指向一個文件夾,再復制這個server到下面,修改端口

          1
          2
          3
          4
          5
          6
          7
          8
          9
          10
          11
          12
          13
          14
          15
          16
          17
          18
          19
          20
          21
          22
          23
          24
          25
          26
          27
          28
          29
          30
          31
          32
          33
          34
          35
          36
          37
          [root@nginx ~]# vim /usr/local/nginx/conf/nginx.conf
          worker_processes  1;
          events {
              worker_connections  1024;
          }
          http {
              include       mime.types;
              default_type  application/octet-stream;
              sendfile        on;
              keepalive_timeout  65;
          #80端口,指向work_01的文件夾
              server {
                  listen       80;
                  server_name  localhost;
                  location / {
                      root   /www/work_01;
                      index  index.html index.htm;
                  }
                  error_page   500 502 503 504  /50x.html;
                  location = /50x.html {
                      root   html;
                  }
              }
          #8080端口,指向work_02的文件夾
              server {
              listen 8080;
              server_name localhost;
              location / {
              root /www/work_02;
              index index.html index.htm;
              }
              error_page 500 502 503 504 /50x.html;
              location = /50x.html {
                  root html;
              }
          }
          }

          #瀏覽器訪問

          二、配置不同域名訪問不同文件

          相同端口,不同域名,不同文件

          #四個文件夾,分別對應不同文件內容

          1
          2
          3
          4
          5
          6
          7
          [root@nginx ~]# cd /www/
          [root@nginx www]# mkdir work_03
          [root@nginx www]# mkdir work_04
          [root@nginx www]# echo "This is work_03" > work_03/index.html
          [root@nginx www]# echo "This is work_04" > work_04/index.html
          [root@nginx www]# ls
          work_01  work_02  work_03  work_04

          #修改配置文件

          1
          2
          3
          4
          5
          6
          7
          8
          9
          10
          11
          12
          13
          14
          15
          16
          17
          18
          19
          20
          21
          22
          23
          24
          25
          26
          27
          28
          29
          30
          31
          32
          33
          34
          35
          36
          37
          38
          39
          40
          41
          42
          43
          44
          45
          46
          47
          48
          49
          50
          51
          52
          53
          54
          55
          56
          57
          58
          59
          60
          61
          62
          63
          [root@nginx www]# vim /usr/local/nginx/conf/nginx.conf
          worker_processes  1;
          events {
              worker_connections  1024;
          }
          http {
              include       mime.types;
              sendfile        on;
              keepalive_timeout  65;
          #通配符在后的域名
              server {
                  listen       80;
                  server_name  www.haha.*;
                  location / {
                      root   /www/work_01;
                      index  index.html index.htm;
                  }
                  error_page   500 502 503 504  /50x.html;
                  location = /50x.html {
                      root   html;
                  }
              }
          #精確域名
              server {
              listen 80;
              server_name www.haha.com;
              location / {
              root /www/work_02;
              index index.html index.htm;
              }
              error_page 500 502 503 504 /50x.html;
              location = /50x.html {
                  root html;
              }
          }
          #通配符在前的域名
              server {
                  listen 80;
                  server_name *.haha.com;
              location / {
                  root /www/work_03;
                  index index.html index.htm;
              }
              error_page 500 502 503 504 /50x.html;
              location = /50x.html {
                  root html;
              }
          }
          #正則表達式域名
              server {
                  listen 80;
                  server_name ~\w+.com;
              location / {
                  root /www/work_04;
                  index index.html index.htm;
              }
              error_page 500 502 503 504 /50x.html;
              location = /50x.html {
                  root html;
              }
          }
          }
          [root@nginx www]# systemctl restart nginx

          #配置宿主機host文件,在"C:\Windows\System32\drivers\etc\hosts"

          #訪問結果

          sever_name匹配順序:

          • 精準匹配
          • 通配符開頭,比如*.example.com
          • 通配符結尾,比如www.example.*
          • 正則表達式
          • 默認值

          三、配置不同域名訪問同個文件

          相同端口,不同域名 ,同個文件

          1
          2
          3
          4
          5
          6
          7
          8
          9
          10
          11
          12
          13
          14
          15
          16
          17
          18
          19
          20
          21
          22
          23
          24
          25
          [root@nginx ~]# vim /usr/local/nginx/conf/nginx.conf
          worker_processes  1;
          events {
              worker_connections  1024;
          }
          http {
              include       mime.types;
              default_type  application/octet-stream;
              sendfile        on;
              keepalive_timeout  65;
          #只需要在server_name再添加一個域名,不需要在復制一個server_name
              server {
                  listen       80;
                  server_name  www.xixi.com www.qiqi.com;
                  location / {
                      root   /www/work_01;
                      index  index.html index.htm;
                  }
                  error_page   500 502 503 504  /50x.html;
                  location = /50x.html {
                      root   html;
                  }
              }
          }
          [root@nginx ~]# systemctl restart nginx

          #該宿主機的host文件

          #訪問結果如下:

          到此這篇關于Nginx主機域名配置實現的文章就介紹到這了

          分享到:

          相關信息

          系統教程欄目

          欄目熱門教程

          人氣教程排行

          站長推薦

          熱門系統下載

          玩家必看科普!麻豆人人妻人人妻人人片AV,欧美老妇交乱视频在线观看,久久综合九色综合久99_知乎 人人玩人人添人人澡超碰偷拍 青春娱乐视频精品分类官网2 最好最新高清中文字幕 91国自产拍最新2018 欧美精品一区二区三区不卡网 深夜你懂得我的意思2021 宿舍NP乖把腿张开H 网恋奔现一天被要几次 为什么我越叫他越快 学渣各种各样的PLAY 英语课代表下面好软小说 亚洲国产综合在线区尤物 FREE性丰满HD性欧美 我年轻漂亮的继坶BD 最近中文字幕完整免费视频 啦啦啦免费视频卡一卡二 青柠视频在线观看大全 在线天堂WWW在线资源 亚洲国产日本韩国欧美MV 天天学习|久久久久久久精品国产亚洲87 国产K频道分享系统进入口 三个嘴都吃满了还塞满了 JAPONENSIS老师学生JAVAHBB 亚洲精品1卡2卡3卡4卡 樱花草在线社区WWW韩国 好涨水快流出来了快吃动视频 久久AV无码精品人妻出轨