vagrant+LNMP一键安装包 报500错误

作者:matrix 被围观: 4,691 次 发布时间:2017-09-28 分类:零零星星 | 一条评论 »

这是一个创建于 2407 天前的主题,其中的信息可能已经有所发展或是发生改变。

图片3791-vagrant+LNMP一键安装包的问题

问题

vagrant中的ubuntu环境安装了Lnmp一键安装包,TP5项目死活都无法访问,一直报错500,502。各种修改nginx.conf,最终还是需要查看nginx的error日志排查问题。

PHP message: PHP Warning:  require(/vagrant/bj-admin/thinkphp/start.php): failed to open stream: Operation not permitted in /vagrant/bj-admin/public/index.php on line 35
PHP message: PHP Fatal error:  require(): Failed opening required '/vagrant/bj-admin/public/../thinkphp/start.php' (include_path='.:/usr/local/php/lib/php') in /vagrant/bj-admin/public/index.php on line 35" while reading response header from upstream, client: 10.10.10.1, server: admin.esc.com, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/tmp/php-cgi.sock:", host: "admin.esc.com"
2017/09/28 13:19:09 [error] 1445#0: *1 FastCGI sent in stderr: "PHP message: PHP Warning:  require(): open_basedir restriction in effect. File(/vagrant/bj-admin/thinkphp/start.php) is not within the allowed path(s): (/vagrant/bj-admin/public/:/tmp/:/proc/) in /vagrant/bj-admin/public/index.php on line 35

就是如上的各种无法require,PHP中逐行exit. 用tail -f查看*error.log文件变化 太逗。
网上找好久解决办法,突然间发现关键字open_basedir,.user.ini 貌似这鬼东西有限制啊。早该想到Operation not permitted就是无权限和LNMP一键包的.user.ini有关就没这么多鸟事了。 因为TP5项目需要把的/public搞成web的root路径,LNMP默认使用.user.ini配置信息来防止跨站点目录访问 导致open_basedir的设置值限制了php的访问权限,也就not permitted。但是线上环境为什么没这个问题,这就不知道了。

解决方案

取消open_basedir限制
可以手动删除或者注释ini,最好使用lnmp一键包的工具脚本

> cd ~/lnmp1.4/tools  #进入lnmp一键包的tool目录
> ./remove_open_basedir_restriction.sh #执行脚本,按照选项操作
> ./remove_disable_function.sh #正巧这个我需要

P.S.
到现在用了差不多一个月的vagrant来模拟ubuntu生产环境,效果很棒。这个问题是上次遗留下来的,搞得我想打人了。一直等到今天接手TP5的项目继续搞 弄了一上午才好。 peace~

参考:
https://m.aliyun.com/yunqi/articles/34240
https://lnmp.org/faq/lnmp-vhost-add-howto.html
http://www.vpser.net/security/lnmp-cross-site-corss-dir-security.html

其他文章:
本文固定链接:https://www.hhtjim.com/the-vagrant-lnmp-a-key-problem-of-installing-packages.html
matrix
本文章由 matrix 于2017年09月28日发布在零零星星分类下,目前没有通告,你可以至底部留下评论。
转载请注明:vagrant+LNMP一键安装包 报500错误-HHTjim'S 部落格
关键字:,

有1条评论 »

  1. 耐火砖 耐火砖 2017-12-28 8:53:08 +0800#1

    学习了,不错。

添加新评论 »

 🙈 😱 😂 😛 😭 😳 😀 😆 👿 😉 😯 😮 😕 😎 😐 😥 😡 😈 💡

插入图片

NOTICE: You should type some Chinese word (like “你好”) in your comment to pass the spam-check, thanks for your patience!