zoukankan      html  css  js  c++  java
  • Nginx之server和location配置使用

    配置server代码段:

    server {
         server_name www.meiduo.site;
         listen 8080;
         root /home/python/Desktop/meiduo_mall_admin/dist;
         index index.html;
    }

    其中:

    server_name : 监听的域名

    listen : 监听的端口

    root : 网站的根路径

    index : 默认访问的文件

    配置location代码段:

    server {
         server_name www.meiduo.site;
         listen 8080;
         location / {
             root /home/python/Desktop/meiduo_mall_admin/dist;
             index index.html;
        }
     }

    其中:

    location字段需要写在server字段内,一个server字段可以包含多个location字段。

    其余属性意思同上。

    注意:

    location _ {} :这里的_表示匹配规则,加上=_表示严格匹配,不加_表示不严格匹配。

    例如:

    server {
        server_name www.meiduo.site;
        listen 8080;
        location / {
            root /home/python/Desktop/meiduo_mall_admin/dist;
            index index.html;
         }
        # 表示只有输入www.meiduo.site/image/时,才走这个location
         location =/image/ {
             root /home/python/Desktop/meiduo_mall_admin/dist;
             index index.html;
         }
     }

     在配置完配置文件以后,需要测试一下语法是否出错和重新加载配置文件。

    sudo nginx -t
    sudo nginx -s reload
    该花的钱要花,该吃的饭要吃。
  • 相关阅读:
    bzoj5328: [Sdoi2018]物理实验
    HDU
    bzoj4820: [Sdoi2017]硬币游戏
    bzoj4600: [Sdoi2016]硬币游戏
    阿里云配置防火墙规则
    博客园 添加 Live 2D 模型
    R语言做逻辑回归
    R语言错误的提示(中英文翻译)
    用随机森林分类
    python 切换虚拟环境
  • 原文地址:https://www.cnblogs.com/chao666/p/12340735.html
Copyright © 2011-2022 走看看