nginx File not found 错误

简介: 使用php-fpm解析PHP,"No input file specified","File not found"是常见错误,原因是php-fpm进程找不到SCRIPT_FILENAME配置的要执行的.php文件,php-fpm返回给nginx的默认404错误提示。

使用php-fpm解析PHP,"No input file specified","File not found"是常见错误,原因是php-fpm进程找不到SCRIPT_FILENAME配置的要执行的.php文件,php-fpm返回给nginx的默认404错误提示。
出现这类错误,十个有九个是后端fastcgi进程收到错误路径(SCRIPT_FILENAME),而后端fastcgi收到错误路径的原因大都是配置错误。
可以参考我的nginx.conf的配置:


#user  nobody;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

    server {
        listen       80;
        server_name  qanme.thenoob.top;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

#这里配置存放网站代码的路径
        location / {
            root   /var/www/web;
            index  index.html index.htm index.php;
        }

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        location ~ \.php$ {
            root          html;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
#输入网址是下载文件多半是下面一行的错误
            fastcgi_param  SCRIPT_FILENAME  /var/www/web$fastcgi_script_name;
            include        fastcgi_params;
        }

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
    }


    # another virtual host using mix of IP-, name-, and port-based configuration
    #
    #server {
    #    listen       8000;
    #    listen       somename:8080;
    #    server_name  somename  alias  another.alias;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}


    # HTTPS server
    #
    #server {
    #    listen       443 ssl;
    #    server_name  localhost;

    #    ssl_certificate      cert.pem;
    #    ssl_certificate_key  cert.key;

    #    ssl_session_cache    shared:SSL:1m;
    #    ssl_session_timeout  5m;

    #    ssl_ciphers  HIGH:!aNULL:!MD5;
    #    ssl_prefer_server_ciphers  on;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}

}

相关文章
|
应用服务中间件 Linux 开发工具
CentOS7下启动Nginx出现Failed to start nginx.service:unit not found
CentOS7下启动Nginx出现Failed to start nginx.service:unit not found
3667 0
CentOS7下启动Nginx出现Failed to start nginx.service:unit not found
|
3月前
|
应用服务中间件 Shell 网络安全
nginx安装提示 libssl.so.3: cannot open shared object file: No
【8月更文挑战第1天】### 原因 未将安装的ssl中的`libssl.so.3`链接到`/usr/lib`导致缺失。 ### 解决方案 1. 检查openssl是否已安装,若为低版本则需重装。 ```sh whereis openssl
1685 6
|
6月前
|
存储 应用服务中间件 nginx
【各种问题处理】nginx报错nginx: [error] open() “/run/nginx.pid” failed (2: No such file or directory)
【1月更文挑战第13天】【各种问题处理】nginx报错nginx: [error] open() “/run/nginx.pid” failed (2: No such file or directory)
|
安全 应用服务中间件 网络安全
用Nginx在win2008服务器部署ssl后xmlhttp异常(msxml6.dll 错误 ‘80072f7d‘ )的解决方法
用Nginx在win2008服务器部署ssl后xmlhttp异常(msxml6.dll 错误 ‘80072f7d‘ )的解决方法
236 1
用Nginx在win2008服务器部署ssl后xmlhttp异常(msxml6.dll 错误 ‘80072f7d‘ )的解决方法
|
应用服务中间件 nginx
404 Not Found 探秘Nginx转发处理流程
404 Not Found 探秘Nginx转发处理流程
428 0
|
前端开发 应用服务中间件 nginx
(最简单详细)关于nginx配置解决页面刷新以后404 Not Found和403 Forbidden
(最简单详细)关于nginx配置解决页面刷新以后404 Not Found和403 Forbidden
2824 0
(最简单详细)关于nginx配置解决页面刷新以后404 Not Found和403 Forbidden
|
应用服务中间件 网络安全 Apache
解决 Nginx Let's Encrypt HTTPS 证书 错误: 服务器缺少中间证书
解决 Nginx Let's Encrypt HTTPS 证书 错误: 服务器缺少中间证书
815 0
解决 Nginx Let's Encrypt HTTPS 证书 错误: 服务器缺少中间证书
|
消息中间件 数据采集 监控
ELK搭建(十二):搭建Nginx访问、错误日志监控平台
Nginx是一款轻量级、高性能的流量分发和反向代理的web服务。随着市场业务量的增加,普通的web容器,如tomcat的并发量已经远不能满足我们的业务量,同时随着分布式架构的普及,我们需要一款反向代理服务的支持,于是Nginx应运而生。 Nginx已经在大多数业务中普遍使用,因此针对Nginx的流量监控,错误日志监控极其必要,这样才能让我们能够及时了解系统运行情况。 那么今天,我们就来看看如何搭建Nginx访问记录、错误日志监控平台
477 0
ELK搭建(十二):搭建Nginx访问、错误日志监控平台
|
应用服务中间件 Linux nginx
centos安装nginx 报错:cp: `conf/koi-win' and `/usr/local/nginx/conf/koi-win' are the same file
centos安装nginx 报错:cp: `conf/koi-win' and `/usr/local/nginx/conf/koi-win' are the same file
1288 0
|
应用服务中间件 nginx
nginx: [error] open() “/usr/local/nginx/logs/nginx.pid“ failed (2: No such file or directory)
nginx: [error] open() “/usr/local/nginx/logs/nginx.pid“ failed (2: No such file or directory)
349 0
nginx: [error] open() “/usr/local/nginx/logs/nginx.pid“ failed (2: No such file or directory)