Home > php教程 > php手册 > Nginx PHP 返回200,但是空白页

Nginx PHP 返回200,但是空白页

WBOY
Release: 2016-06-13 11:33:49
Original
1840 people have browsed it

ngxin;php-fpm安装后,html静态页面没问题,但是phpinfo页面虽然返回200,但总是空白页

也没有任何报错,考虑应该是nginx已经将php页面转移给php处理了,所以问题应该在php的配置上,经过查找,发现需要在nginx中加入一句话
fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;

安装完nginx后默认的fastcgi_params配置文件中没有上面这句话。

在nginx.conf中的
        location ~ .php$ {
            root           html;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            #fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
            fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }
或者在fastcgi_params配置文件中加入
# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param  REDIRECT_STATUS    200;
fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;

然后重启nginx就可以显示出页面了。

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template