PHP头条
热点:

nginx php空白页 fastcgi_param


今天安装完nginx 后 发现html页面能正常浏览 但是php文件的页面打开后是一篇空白 看php-fpm日志 看nginx日志都没找到问题

上网搜索了半天终于解决了,在这做个记录备忘

网上的一种说法是缺少这么一句话在nginx的配置文件里

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

这句话是干嘛的呢 其实他就是定义php中用到的服务器变量 也就是$_SERVER

http://wiki.nginx.org/NginxHttpFcgiModule 这个网址下有这么一句话

This module allows Nginx to interact with FastCGI processes and control what parameters are passed to the process。

其实也就是服务器像你的处理php的cgi传递过去他需要的一些参数,而至少要有下面的两个参数php才能执行起来

Below is an example of the minimally necessary parameters for PHP:

fastcgi_param SCRIPT_FILENAME /home/www/scripts/php$fastcgi_script_name;

fastcgi_param QUERY_STRING $query_string;

Parameter SCRIPT_FILENAME is used by PHP for determining the name of script to execute, and QUERY_STRING contains the parameters of the request.

所以 我们在没有定义SCRIPT_FILENAME这个系统变量的时候 php是没法解释执行的

这个变量的定义可以写在nginx的配置文件nginx.conf里 也可以写在外部 用include的方式在nginx.conf里包含进来。

www.phpzy.comtrue/php/3947.htmlTechArticlenginx php空白页 fastcgi_param 今天安装完nginx 后 发现html页面能正常浏览 但是php文件的页面打开后是一篇空白 看php-fpm日志 看nginx日志都没找到问题 上网搜索了半天终于解决了,在这做个记...

相关文章

    暂无相关文章
相关频道:

PHP之友评论

今天推荐