• 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;
     ...
    }
    
    
    
  • 相关阅读:
    文件的基本操作
    ps工作界面
    HDU 6300
    HDU 6298
    HDU 2037
    HDU 2036
    Tesseract OCR
    What is the difference between position: static,relative,absolute,fixed
    How to Call a synchronize function asynchronizly in C#
    WCF note1
  • 原文地址:https://www.cnblogs.com/iosdev/p/3439834.html
Copyright © 2020-2023  润新知