访问php文件,不能解析或直接下载,nginx.conf中如下配置不正确或未配置
user
www
www
;
index
index
.php
index
.html
index
.htm
;
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#取消FastCGI server部分location的注释,注意fastcgi_param行的参数,改为$document_root$fastcgi_script_name,或者使用绝对路径
location
~
\
.php
$
{
root
html
;
fastcgi
_pass
127.0.0.1
:
9000
;
fastcgi_index
index
.php
;
fastcgi_param
SCRIPT
_FILENAME
$document_root
$fastcgi_script_name
;
include
fastcgi_params
;
}
访问php文件,nginx对PHP文件报File not found 错误
错误原因:配置文件 nginx.conf 中
user
www
www
;
index
index
.php
index
.html
index
.htm
;
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#取消FastCGI server部分location的注释,注意fastcgi_param行的参数,改为$document_root$fastcgi_script_name,或者使用绝对路径
location
~
\
.php
$
{
root
html
;
fastcgi
_pass
127.0.0.1
:
9000
;
fastcgi_index
index
.php
;
fastcgi_param
SCRIPT
_FILENAME
$document_root
$fastcgi_script_name
;
include
fastcgi_params
;
}
fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
改成如下这句,即可
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;