今天准备把之前用tp5框架写的一个小项目上线的服务器上
在windows下没问题,但是上传到服务器后访问接口出现500错误
用的是lnmp的环境,文件上传后把所有权限都打开,都显示
HTTP ERROR 500的错误,服务器内部错误
在入口文件index.php中加入
error_reporting(E_ALL);
ini_set('display_errors', '1');
来打印所有错误信息
Warning: require(): open_basedir restriction in effect. File(/home/wwwroot/mz.kchangfu.cn/thinkphp/start.php) is not within the allowed path(s): (/home/wwwroot/mz.kchangfu.cn/public/:/tmp/:/proc/) in /home/wwwroot/mz.kchangfu.cn/public/index.php on line 22
Warning: require(/home/wwwroot/mz.kchangfu.cn/thinkphp/start.php): failed to open stream: Operation not permitted in /home/wwwroot/mz.kchangfu.cn/public/index.php on line 22
Fatal error: require(): Failed opening required '/home/wwwroot/mz.kchangfu.cn/public/../thinkphp/start.php' (include_path='.:/usr/local/php/lib/php') in /home/wwwroot/mz.kchangfu.cn/public/index.php on line 22
查看问题描述以及资料,发现是php open_basedir 配置的问题,php不能引入其授权目录上级及其以上的文件,默认配置在php.ini(/usr/local/php/etc/php.ini),但是我的open_basedir 并没有配置,默认被注释了。
文献说可能在服务器配置目录下,如nginx、Apache等,于是用户sublime打开nginx进行全局搜索,open_base,果真还是搜到了,如下图
注释掉
/usr/local/nginx/conf/fastcgi.conf