No input file specified. nginx报错解决方案

1 检查这个目录是否存在,路径是否错误,注意Windows目录反斜杠
2 pathinfo配置项要检查清楚,本文提供一个通用的pathinfo配置项
server
    {
        listen 80;
        server_name api.xxx.com;                     #域名
        index index.html index.htm index.php;  #自动定位index.php
        root  /home/wwwroot/default/demo;      #项目目录
        location / {                                             #隐藏index.php配置
            if ( -f $request_filename) {                #如果是常规文件,不做处理
                break;
            }
            if ( !-e $request_filename) {             #如果访问的目录不存在,择把目录部分追加到index.php后面
                rewrite ^(.*)$ /index.php/$1 last;
                break;
            }
        }

        location ~ [^/]\.php(/|$)                         #pathinfo php配置
        {
            #try_files $uri =404;
            fastcgi_pass  unix:/tmp/php-cgi.sock;
            fastcgi_index index.php;
            include fastcgi.conf;
            fastcgi_split_path_info  ^((?U).+\.php)(/?.+)$;
            fastcgi_param  SCRIPT_FILENAME  /home/wwwroot/default/demo$fastcgi_script_name;
            fastcgi_param  PATH_INFO  $fastcgi_path_info;
        }

        location /nginx_status
        {
            stub_status on;
            access_log   off;
        }

        location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
        {
            expires      30d;
        }

        location ~ .*\.(js|css)?$
        {
            expires      12h;
        }

        location ~ /.well-known {
            allow all;
        }

        location ~ /\.
        {
            deny all;
        }

        access_log  /home/wwwlogs/access.log;
    }

然后 查看php.ini配置把下面两个 参数进行修改

cgi.force_redirect = 0
cgi.fix_pathinfo=1
在nginx的配置文件里找到fastcgi.conf,注释掉目录 限制
#fastcgi_param PHP_ADMIN_VALUE "open_basedir=$document_root/:/tmp/:/proc/";

搜索fastcgi_param命令

 grep "fastcgi_param" ./*

LNMP 一键安装的用户可直接切换到目录编辑fastcgi.conf

cd /usr/local/nginx/conf && vim ./fastcgi.conf

# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param  REDIRECT_STATUS    200;
#fastcgi_param PHP_ADMIN_VALUE "open_basedir=$document_root/:/tmp/:/proc/";