Windows上的NGINX和php-cgi“未指定输入文件”

乔希

我正在运行php-cgi和NGINX。它们在一个文件夹中运行,但是其根目录在其中2个目录中,而在其中2个目录中。当根是html(默认值)时,它们可以正常工作,但是现在php报告“未指定输入文件”错误。我尝试设置目录以完全控制所有程序,我已经拥有完全控制权,我尝试查看php是否在其他目录中查找,尝试更改目录,对php变量进行硬编码等。已经按照有关如何解决此问题的5种不同的教程进行了介绍,但没有一个解决方案。控制台中没有错误,并且我的fastcgi.conf保持不变。php和NGINX都可以正常运行并且可以通信,但是php由于某种原因无法获取文件。访问任何非PHP文件时,NGINX成功检索了文件,我的浏览器显示了该文件。我已经使用netstat验证了,唯一监听9100端口的是我的php-cgi。而且,唯一监听8080端口的是NGINX。php和NGINX均配置为正确通信,并且php-cgi通过php目录中的RunHiddenConsole.exe运行。

这是目录树,格式类似于YAML:

EclipsePHP
    - Code
        - Blog
            - Source (NGINX/php root Location/Website Source Files)
    - NGINX
        - 1.9.11 (NGINX Executable Location)
            - php (php Executable Location)

还有我的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 {
    client_max_body_size 5G;
    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 {
        root   ../../Code/Blog/Source;
        client_max_body_size 5G;
        listen       8080;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            index  index.php;
            try_files $uri $uri.html $uri/ @extensionless-php;
            index index.html index.htm index.php;
            client_max_body_size 5G;
        }

        error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #

        recursive_error_pages off;

        # 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$ {
            client_max_body_size 5G;
            try_files      $uri =404;
            include        fastcgi.conf;
            include        fastcgi_params;
            fastcgi_pass   127.0.0.1:9100;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        }

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

        location @extensionless-php {
             rewrite ^(.*)$ $1.php last;
        }
    }


    # 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;
    #    }
    #}

}

什么可能是造成此错误的原因,如何解决该错误,以便可以在浏览器中正确查看php文件?(我正在使用Eclipse PHP编辑源代码,无论是否运行Eclipse,都会发生该错误。)

乔希

由于php不喜欢相对目录,因此我的解决方案是在每次启动时使用批处理设置绝对目录。在启动NGINX之前,我在批处理启动脚本中插入了以下内容。

set TEXT_FILE=conf\phploc.conf
set REL_PATH=..\..\Code\Blog\Source
set ABS_PATH=
pushd %REL_PATH%
set ABS_PATH=%CD%
popd
echo fastcgi_param  SCRIPT_FILENAME  %ABS_PATH%$fastcgi_script_name; > %TEXT_FILE%

然后,在NGINX配置文件中,我将以下内容插入php位置块以加载目录设置。

include phploc.conf;

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

使用Laravel Homestead:“未指定输入文件”

Docker的php-fpm错误“未指定输入文件”

未指定输入文件-Apache和php-fastcgi

无业游民“未指定输入文件。”

http://localhost/phpmyadmin/index.php“未指定输入文件。” nginx Windows Server 2012的PHP 7

Nginx,fastcgi PHP Windows,未指定输入文件

cPanel cron作业,未指定输入文件?

NGINX-未指定输入文件

PHP错误:“未指定输入文件。” 在IIS 10.0,本地开发服务器上的PHP 5.6中

未指定输入文件:无法配置NGINX别名

当路由为PHP文件时,页面将显示错误。未指定输入文件

nginx:将单个静态URL映射到PHP文件?未指定输入文件

使用Laravel Homestead:“未指定输入文件”

WordPress永久链接-NGINX Conf(未指定输入文件错误)

Laravel Cronjob ::状态:404未找到X-Powered-By:PHP / 7.3.20内容类型:text / html; charset = UTF-8未指定输入文件

对于某些版本的PHP,“未指定输入文件”

Pyro CMS-未指定输入文件

htaccess阻止“未指定输入文件”。信息

如何检测文件上使用的压缩类型?(如果未指定文件扩展名)

Nginx,臭名昭著的“未指定输入文件”,包括解决方案以及有关所需解决方案的可能解释

NGINX sef urls错误:未指定输入文件

PhpStorm内置Web服务器不适用于PHP,并导致“未指定输入文件”错误

无法将文件/文件夹添加到Windows 10上的快速访问中:“未指定的错误”

.htaccess“未指定输入文件”错误

Nginx + php fastcgi显示“未指定输入文件”。而不是404

Codeigniter 未指定输入文件

PHP Slim 框架:未指定输入文件?

NGINX - 未指定输入文件。- php-fpm

如何在未指定文件和指定文件不存在时引发异常?pyth