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;
    }
  • 相关阅读:
    final修饰符
    数组知识点
    session的作用范围(转)
    c++之list学习
    C++之重载操作符
    C++之浅拷贝构造函数与深拷贝构造函数
    C++之友元
    C++之共有继承、保护继承、私有继承
    C++之类静态成员变量和静态成员函数
    C源程序到可执行文件的四个过程
  • 原文地址:https://www.cnblogs.com/captainmoore/p/11557788.html
Copyright © 2011-2022 走看看