PHP No input file specified 解决办法

PHP Nginx About 1,918 words

场景

Windowsphp-cgiNginxThinkPHP

启动 php-cgi

监听9000端口,指定配置文件

.\php-cgi.exe -b 127.0.0.1:9000 -c php.ini

启动 Nginx

更改配置

监听9527端口,转发请求到9000端口。

server {
    listen       9527;
    server_name  localhost;
    root   C:\thinkphp5.1\public;
    location / {
        index  index.html index.htm index.php;
            #autoindex  on;
        if (!-e $request_filename) {
            rewrite  ^(.*)$  /index.php?s=/$1  last;
            break;
        }
    }

    location ~ \.php(.*)$ {
        fastcgi_pass   127.0.0.1:9000;
        #fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
        fastcgi_index  index.php;
        fastcgi_split_path_info  ^((?U).+\.php)(/?.+)$;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        fastcgi_param  PATH_INFO  $fastcgi_path_info;
        fastcgi_param  PATH_TRANSLATED  $document_root$fastcgi_path_info;
        include        fastcgi_params;
    }
}

错误信息

访问localhost:9527,页面出现No input file specified.文字并未展示页面。

尝试解决

网上有说修改php.ini文件中的;cgi.fix_pathinfo=1中的注释打开(去掉;),但没有解决我的问题。

;cgi.fix_pathinfo=1

解决办法

修改nginx.conf,将root中填写的路径C:\thinkphp5.1\public改为C:/thinkphp5.1/public,即可。

server {
    listen       9527;
    server_name  localhost;
    root   C:/thinkphp5.1/public;
    location / {
        index  index.html index.htm index.php;
            #autoindex  on;
        if (!-e $request_filename) {
            rewrite  ^(.*)$  /index.php?s=/$1  last;
            break;
        }
    }

    location ~ \.php(.*)$ {
        fastcgi_pass   127.0.0.1:9000;
        #fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
        fastcgi_index  index.php;
        fastcgi_split_path_info  ^((?U).+\.php)(/?.+)$;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        fastcgi_param  PATH_INFO  $fastcgi_path_info;
        fastcgi_param  PATH_TRANSLATED  $document_root$fastcgi_path_info;
        include        fastcgi_params;
    }
}
Views: 3,391 · Posted: 2021-07-05

————        END        ————

Give me a Star, Thanks:)

https://github.com/fendoudebb/LiteNote

扫描下方二维码关注公众号和小程序↓↓↓

扫描下方二维码关注公众号和小程序↓↓↓


Today On History
Browsing Refresh