【问题标题】:Nginx + php-fpm returning either a blank page or "no input file specified"Nginx + php-fpm 返回空白页或“未指定输入文件”
【发布时间】:2015-10-05 17:20:35
【问题描述】:

我在 Debian 稳定系统上使用 nginx 和 php5-fpm。这是我的默认站点:

server {
listen 443 default_server;
server_name _;

root /home/www/known;

# Deny access to dot files and dirs
location ~ /\. {
    access_log off;
    log_not_found off;
    deny all;
}

# Enable PHP for vhosts
index index.php index.html index.htm index.nginx-debian.html;
location ~ \.php$ {
    # regex to split $uri to $fastcgi_script_name and $fastcgi_path
    fastcgi_split_path_info ^(.+\.php)(/.+)$;

    # Check that the PHP script exists before passing it
    try_files $fastcgi_script_name =404;

    # Bypass the fact that try_files resets $fastcgi_path_info
    # see: http://trac.nginx.org/nginx/ticket/321
    set $path_info $fastcgi_path_info;
    fastcgi_param PATH_INFO $path_info;

    fastcgi_index index.php;
    include fastcgi.conf;

    fastcgi_pass   unix:/var/run/php5-fpm.sock;
}

ssl on;
ssl_certificate /etc/ssl/certs/phyks.me/root.crt;
ssl_certificate_key /etc/ssl/private/phyks.me/root.key;

location / {
    # First attempt to serve request as file, then
    # as directory, then fall back to displaying a 404.
    try_files $uri $uri/ =404;
}
}

PHP 部分取自 Debian 中与 Nginx 捆绑的 php fastcgi sn-p。 /home/www/known/index.php 文件存在并且可由 www-data 读取(nginx 和 php-fpm 都运行)但我得到一个“没有指定输入文件”尽管文件路径由 nginx 正确传递到 php-fpm。

我尝试将 php 文件的位置块的内容替换为

include fastcgi_params;
fastcgi_pass   unix:/var/run/php5-fpm.sock;

在这种情况下,我有一个空白页面(状态为 200)并且无法从 php5-fpm 或 nginx 获取任何详细的日志输出。

我已经被困了几个小时,尝试不同的配置选项,但无法弄清楚发生了什么……你有什么想法吗?此外,类似的配置也适用于其他服务器。

谢谢!

【问题讨论】:

    标签: php nginx


    【解决方案1】:

    请检查您的/etc/nginx/fastcgi.conf/etc/nginx/fastcgi_params 是否包含此param SCRIPT_FILENAME $request_filename; 或将其附加到文件中。

    【讨论】:

    • 这没有提供问题的答案。要批评或要求作者澄清,请在其帖子下方发表评论。
    • @dhh:请详细说明一下,因为对于可怜的 nginx 配置器,例如我的答案似乎可能确实有效。
    • 在 Ubuntu 16.04 中,"fastcgi.conf 和 "fastcgi_params" 都提供了。唯一的区别是 fastcgi.conf 包含 SCRIPT_FILENAME 设置。将包含行切换到 "include fastcgi.conf;" 拉进来设置。很烦人,因为即使打开调试,PHP FPM 也不会记录任何错误。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-05-26
    • 1970-01-01
    • 2018-03-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多