zoukankan      html  css  js  c++  java
  • File not found 错误 nginx

    这个错误很常见,很明显找不到文件。

    原因是php-fpm找不到SCRIPT_FILENAME里执行的php文件,所以返回给nginx 404 错误。

    那么两种情况要么文件真的不存在,要么就是路径错误。

    location / {
            root   /var/www/example.com;
            index  index.html index.htm index.pl;
        }
    

    如果配置文件这样的,那么明显不好,也就是在

    location ~ .php$ {
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME #document_root$fastcgi_script_name;
            include fastcgi_params;
        }
    

     这里的document就找不到document_root,所以可以把root放在location外面试试看或者在

    location ~ .php$ {}

    里面加上root.

    如果文件真的不存在的话,因为nginx检查$uri是不是.php结尾,不检查是不是存在,所以找不到时候就返回404错误。“No input file specified”

    如果是这样的话,在配置文件种用try_files就可以检查是否存在了。

    不存在就返回404.

    location ~ .php$ {
     try_files $uri =404;
     fastcgi_pass 127.0.0.1:9000;
     fastcgi_index index.php;
     ...
    }
    
    
    
  • 相关阅读:
    第五章课后练习题
    第四章课后练习
    函数
    变量、常量及类型
    go环境搭建及编辑器安装
    Matplotlib(绘图和可视化)
    Pandas例题(以NBA球队为例)
    Pandas
    Numpy
    jupyter notebook编辑器的用法
  • 原文地址:https://www.cnblogs.com/iosdev/p/3439834.html
Copyright © 2011-2022 走看看