您好,欢迎访问一九零五行业门户网

Nginx+php fastcgi 发生 Access Denied

nginx+php fastcgi 发生 access denied
2014-06-10 18:10 4901人阅读 评论(0) 收藏 举报
原因分析:
php官方从5.3.9开始,加入了一个配置security.limit_extensions(/usr/local/php/etc/php-fpm.conf),默认状态下只允许执行扩展名为.php的文件,造成了其他类型的文件不支持的问题。
如果你请求的 地址是  css js png这种资源 会被 php 拒绝,如果你请求的是 http://localhost/user   (暗含  http://localhost/user/index.php)也是不行的。
解决方式
1,有的人修改 php的配置文件 将 允许的扩展 都加上 比如security.limit_extensi .html .js .css .jpg .jpeg .gif .png .htm#
但是这样其实是不好的 因为静态资源本来就不应该让php fast-cgi处理
2,(推荐)使用nginx的rewrite
location  ~ \.(js|css|gif|jpg|jpeg|png)$ {
    root   d:/tmp;
}
location  ~ \.php$ {
            root           html;
            fastcgi_pass   127.0.0.1:3344;
            fastcgi_index  index.php;
            fastcgi_param  script_filename  d:/tmp/$fastcgi_script_name;
            include        fastcgi_params;
}
location   / {
            root           d:/tmp/film;
            fastcgi_pass   127.0.0.1:3344;
            fastcgi_index  index.php;
            fastcgi_param  script_filename  d:/tmp/film/$fastcgi_script_name;
            include        fastcgi_params;
            rewrite        ^(.*)$      $1/index.php;
}
如此可以较好解决问题 第一个location过滤类型 可能不够,可以根据自己的需求添加
以上就介绍了nginx+php fastcgi 发生 access denied,包括了方面的内容,希望对php教程有兴趣的朋友有所帮助。
其它类似信息

推荐信息