nginx 解析PHP
时间:2009-12-14
来源:互联网
装完nginx之后不能解析PHP文件,返回
404 Not Found 或者 返回了PHP文件的代码
因为以前没有接触过nginx ,所以查了一天,查处原因有二:
一、网站根目录
默认是在 /usr/local/nginx/html文件
配置在
location / {
root /home/www/wwwroot;
index index.html index.htm;
}
二、修改文件中对应的php配置部分
location ~ \.php$ {
root /home/www/wwwroot;
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这个参数默认的是$fastcgi_script_name;最好改为$document_root$fastcgi_script_name;我在实际配置中出现了php找不到需要解析文件而返回404或者500错误的问题。所以最好是带上网站根目录的路径变量$document_root
原文地址 http://blog.csdn.net/bookmoth/archive/2009/09/18/4568203.aspx
404 Not Found 或者 返回了PHP文件的代码
因为以前没有接触过nginx ,所以查了一天,查处原因有二:
一、网站根目录
默认是在 /usr/local/nginx/html文件
配置在
location / {
root /home/www/wwwroot;
index index.html index.htm;
}
二、修改文件中对应的php配置部分
location ~ \.php$ {
root /home/www/wwwroot;
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这个参数默认的是$fastcgi_script_name;最好改为$document_root$fastcgi_script_name;我在实际配置中出现了php找不到需要解析文件而返回404或者500错误的问题。所以最好是带上网站根目录的路径变量$document_root
原文地址 http://blog.csdn.net/bookmoth/archive/2009/09/18/4568203.aspx
作者: zhoulian 发布时间: 2009-12-14
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28