本文介绍了nginx 显示空白的 PHP 页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have setup an nginx server with php5-fpm. When I try to load the site I get a blank page with no errors. Html pages are served fine but not php. I tried turning on display_errors in php.ini but no luck. php5-fpm.log is not producing any errors and neither is 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 错误日志:

here's my nginx error log:

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"

推荐答案

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

For reference, I am attaching my location block for catching files with the .php extension:

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

仔细检查 /path/to/fastcgi-params,并确保它存在并且可供 nginx 用户读取.

Double-check the /path/to/fastcgi-params, and make sure that it is present and readable by the nginx user.

这篇关于nginx 显示空白的 PHP 页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-24 06:13