博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
lnmp环境的nginx的tp5配置
阅读量:4581 次
发布时间:2019-06-09

本文共 1871 字,大约阅读时间需要 6 分钟。

  php7.1

1 server { 2   listen 80; 3   server_name www.tp5.com; 4   access_log  /home/wwwroot/access.log  combined; 5   error_log /home/wwwroot/error.log; 6  7   set $root /home/wwwroot/default/mytp5/tp5/public; 8  9   location ~ \.php {10         fastcgi_pass unix:/tmp/php-cgi.sock;11         fastcgi_split_path_info ^((?U).+.php)(/?.+)$;12         fastcgi_param PATH_INFO $fastcgi_path_info;13         fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;14         fastcgi_param    SCRIPT_FILENAME    $root$fastcgi_script_name;15         include        fastcgi_params;16     }17     location ~ .*\.(gif|jpg|jpeg|bmp|png|ico|txt|js|css)$18     {19         root $root;20     }21     location / {22         root    $root;23         index    index.html index.php;24         if ( -f $request_filename) {25             break;26         }27         if ( !-e $request_filename) {28             rewrite ^(.*)$ /index.php/$1 last;29             break;30         }31     }32 33 34 }

如果出现了错误

 

1 FastCGI sent in stderr: "Access to the script '/usr/local/nginx/html' has been denied (see security.limit_extensions)" while reading response header from upstream, client: 192.168.124.1, server: www.tp5.com, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/tmp/php-cgi.sock:", host: "www.tp5.com"
  1. 在你php-fpm配置文件php-fpm.conf中设置security.limit_extensions 为 .php 或 .php5,或者其他任何与你环境一致的后缀名。 对于开发环境下的一些用户来说, 完全移除所有security.limit_extensions的值或设置为FALSE,能够保证可以正常工作.

     

  2. 在你的nginx配置文件中设置fastcgi_pass 为你的socket地址(e.g. unix:/var/run/php-fpm/php-fpm.sock;), 替代ip地址:端口这种方式(127.0.0.1:9000).

     

  3. 检查你的SCRIPT_FILENAMEfastcgi_param 并根据你文件的地址来设置它们.

  4. 在你的nginx配置文件中包含有fastcgi_split_path_info ^(.+\.php)(/.+)$; 则所有其他的对应fastcgi参数也都应该在location块中定义;具体可参考

  5. 在你的php.ini配置文件中,设置cgi.fix_pathinfo=1

我就是因为第五个原因,cgi.fix_pathinfo默认没有设置为1,而造成页面总是显示Access denied

 

转载于:https://www.cnblogs.com/matengfei123/p/9036541.html

你可能感兴趣的文章
资源相互引用时 需添加 PerformSubstitution=True
查看>>
MapRedece(单表关联)
查看>>
蒲公英App开发之检测新版本
查看>>
【安卓基础】倒计时按钮封装(验证码倒计时按钮)
查看>>
configparser模块
查看>>
SelectQueryBuilder的用法
查看>>
android的用户定位(一)
查看>>
creat-react-app搭建的项目中按需引入antd以及配置Less和如何修改antd的主题色
查看>>
IIS安装
查看>>
html块级元素和行级元素的区别和使用
查看>>
for循环嵌套
查看>>
寒冬夜行人
查看>>
poj1151 Atlantis
查看>>
HTML页面之间的参数传递
查看>>
java面试题集锦
查看>>
scikit-learn:4.2.3. Text feature extraction
查看>>
Spring Security构建Rest服务-0800-Spring Security图片验证码
查看>>
AE待整理
查看>>
java8中规范的四大函数式接口
查看>>
宝塔apache配置
查看>>