Nginx + php-fpm返回空白页面或“未指定输入文件”

时间:2015-07-16 10:06:19

标签: php nginx

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

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文件的位置块的内容
include fastcgi_params;
fastcgi_pass   unix:/var/run/php5-fpm.sock;

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

我已经陷入困境,尝试不同的配置选项,但无法弄清楚发生了什么......你有什么想法吗?加上类似的配置也适用于其他服务器。

谢谢!

1 个答案:

答案 0 :(得分:3)

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