php - Nginx + php-fpm 返回空白页面或 "no input file specified"

标签 php nginx

我在 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 片段。/home/www/known/index.php 文件存在并且可由 www-data 读取(nginx 和 php-fpm 都运行),但我得到“未指定输入文件”,尽管 nginx 正确传递了文件路径到 php-fpm。

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

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

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

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

谢谢!

最佳答案

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

关于php - Nginx + php-fpm 返回空白页面或 "no input file specified",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31451221/

相关文章:

amazon-web-services - 如何避免使用Nginx配置进行AWS ELB健康检查的基本身份验证

php - 在 Laravel 5 的中间件网络组中获取子域

php - 是否可以使用mysql查询下载大型数据库

php - laravel TokenMismatchException 文件上传超过 8MB

ruby-on-rails - 在 Rails 2.3.12 和 HTTPS 中安装机架应用程序失败

amazon-web-services - Amazon ECS - 在 Docker 入口点上使用 IAM 角色时权限被拒绝

php - 海量产品类别更新(为所有产品添加 `home` 类别) - Prestashop 1.6.0.6

php - 将具有自定义价格的产品添加到在 WooCommerce 中以编程方式创建的订单

nginx 服务器有时会返回 404 Not Found 以获得有效的 URL

node.js - 将 MEAN 堆栈应用程序部署到现有服务器