Chinaunix首页 | 论坛 | 博客
  • 博客访问: 69807
  • 博文数量: 11
  • 博客积分: 1410
  • 博客等级: 上尉
  • 技术积分: 80
  • 用 户 组: 普通用户
  • 注册时间: 2009-07-04 16:01
文章分类
文章存档

2009年(11)

我的朋友

分类: 系统运维

2009-11-21 09:43:30

装完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

阅读(3281) | 评论(0) | 转发(0) |
0

上一篇:Centos Vftp

下一篇:Discuz!7.1安装(三)

给主人留下些什么吧!~~