Heim  >  Artikel  >  Backend-Entwicklung  >  nginx php空白页 fastcgi_param_PHP教程

nginx php空白页 fastcgi_param_PHP教程

WBOY
WBOYOriginal
2016-07-22 09:02:39841Durchsuche

今天安装完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.bkjia.comtruehttp://www.bkjia.com/PHPjc/371849.htmlTechArticle今天安装完nginx 后 发现html页面能正常浏览 但是php文件的页面打开后是一篇空白 看php-fpm日志 看nginx日志都没找到问题 上网搜索了半天终于...
Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn