您的位置:首页 > 运维架构 > Nginx

nginx常见错误---持续更新

2014-03-13 14:15 253 查看
1.nginx对PHP文件报File not found.错

今天在配置nginx+php5.4的时候,配置完成后,浏览器打开php文件就提示File not found.错误。

纠结半天,终于发现错误的地方了:

fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;

改成如下这句,即可

fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;

server { 

listen        80; 

server_name   *.example.com; 

root          /home/nginx/vhosts/example.com/web;

    location / { 

        index     index.php;

    } 

    location ~ \.php$ { 

        root /home/nginx/vhosts/example.com/web; 

        fastcgi_pass   127.0.0.1:9001;            fastcgi_index index.php; 

        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;

        include        /etc/nginx/fastcgi_params; 

    } 
}

2.Nginx访问二级目录的时候不加/(反斜杠)无法访问

if (-d $request_filename){
rewrite ^/(.*)([^/])$ http://$host/$1$2/ permanent;
}

3.[emerg]: unknown directive "if($request_method" in /export/servers/nginx/conf/nginx.conf:86

一种是少pcre包

另一种是:
if 和括号间需要空格,坑爹啊


内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: