zoukankan      html  css  js  c++  java
  • Nginx配置中遇到到的问题和解决方案

    Nginx配置文件相关


    关于Nginx配置中遇到到的问题和解决方案

    整理知识,学习笔记

    Nginx配置别名(alias)及PHP解析

    Nginx配置别名(alias)及PHP解析。


    Location配置详细解释

    语法规则: location [=||*|^~] /uri/ { … }

    = 开头表示精确匹配
    ^~ 开头表示uri以某个常规字符串开头,理解为匹配 url路径即可。nginx不对url做编码,因此请求为/static/20%/aa,可以被规则^~ /static/ /aa匹配到(注意是空格)。

    ~ 开头表示区分大小写的正则匹配

    ~* 开头表示不区分大小写的正则匹配

    !和!*分别为区分大小写不匹配及不区分大小写不匹配 的正则

    / 通用匹配,任何请求都会匹配到。

    配置文件示例

    Listen 80;
    server_name localhost;
    root /var/www/html;
    
    # Add index.php to the list if you are using PHP
    index index.php index.html index.htm index.nginx-debian.html;
    
    location ~ /nav/.+.php$ {
        if ($fastcgi_script_name ~ /nav/(.+.php.*)$) {
         set $valid_fastcgi_script_name $1;
        }
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param SCRIPT_FILENAME /www/phpcms/$valid_fastcgi_script_name;
        include    fastcgi_params;
    }
    
    location /nav {
        alias /www/phpcms;
        index index.html index.php;
    }
    
    location ~ .php$ {
        root       /var/www/html;
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include    fastcgi_params;
    }
  • 相关阅读:
    iOS开发工具
    Runtime 自动化归档
    iOS事件拦截及应用
    NoSuchFieldError
    微信开放平台创建android应用时怎么获取应用签名
    高德地图添加marker及反地理编码获取POI
    快速创建导航栏
    Android Studio 工具栏添加常用按钮
    undefined is not an object (evaluating 'RNFetchBlob.DocumentDir')
    React-Native集成到已有项目中的总结
  • 原文地址:https://www.cnblogs.com/captainmoore/p/11557788.html
Copyright © 2011-2022 走看看