2023-04-23 22:29:50 阅读( 3441)
今天安装完nginx后发现html页面能正常浏览但是php文件的页面打开后是一篇空白看php-fpm日志看nginx日志都没找到问题上网搜索了半天终于解决了,在这做个记录备忘网上的一种说法是缺少这么一句话在nginx的配置文件里fastcgi_paramSCRIPT_FILENAME$document_r
This module allows Nginx to interact with the FastCGI process and control the parameters 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.
所以php无法解释我们没有定义系统变量SCRIPT_FILENAME时的执行情况。
这个变量的定义可以写在nginx的配置文件nginx.conf中,也可以外部编写,通过include的方式包含在nginx.conf中。
猜你喜欢
Guessyoulike