nginx 显示空白的 PHP 页面

2022-08-30 06:30:19

我已经用php5-fpm设置了一个nginx服务器。当我尝试加载网站时,我得到一个空白页面,没有错误。Html页面服务很好,但不是php。我尝试在php中打开display_errors.ini但没有运气。php5-fpm.log不会产生任何错误,nginx也不会。

nginx.conf

server {
    listen 80;
    root /home/mike/www/606club;
    index index.php index.html;
    server_name mikeglaz.com www.mikeglaz.com;
    error_log /var/log/nginx/error.log;
    location ~ \.php$ {
            #fastcgi_pass 127.0.0.1:9000;
            # With php5-fpm:
            fastcgi_pass unix:/var/run/php5-fpm.sock;
            fastcgi_index index.php;
            include fastcgi_params;
    }
}

编辑

这是我的nginx错误日志:

2013/03/15 03:52:55 [error] 1020#0: *55 open() "/home/mike/www/606club/robots.txt" failed (2: No such file or directory), client: 199.30.20.40, server: mikeglaz.com, request: "GET /robots.txt HTTP/1.1", host: "mikeglaz.com"

答案 1

取代

include fastcgi_params;

include fastcgi.conf;

并删除fastcgi_param SCRIPT_FILENAME...in nginx.conf


答案 2

作为参考,我附加了我的块,用于捕获扩展名的文件:location.php

location ~ \.php$ {
    include /path/to/fastcgi_params;
    fastcgi_pass  127.0.0.1:9000;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
}

仔细检查 ,并确保它存在并且可供nginx用户读取。/path/to/fastcgi_params


推荐