您现在的位置是:网站首页> 编程资料编程资料
nginx php空白页 fastcgi_param_资源网
2022-05-15
952人已围观
简介 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里包含进来。
相关内容
- nginx + php-fpm页面显示空白的问题_资源网
- php-cgi进程cpu占用资源过高的原因及解决方法_资源网
- Nginx 504 Gateway Time-out问题的解决经历_资源网
- 完美解决Nginx 504 Gateway time-out_资源网
- LNMPA遇到504 Gateway time-out错误的解决方法_资源网
- 解决 502、504 Gateway Time-out(nginx)_资源网
- nginx 502 bad gateway_资源网
- IIS7配置PHP环境完整图文教程_资源网
- nginx下无法访问中文文件名的解决方法_资源网
- Nginx支持中文文件名方法_资源网
