open_basedir restriction in effect错误解决方法

一、前言

    今天在Ubuntu安装了lnmp环境,运行项目的时候出现了,引入500的错误
open_basedir restriction in effect错误解决方法_第1张图片


二、查看错误

  再项目文件入口添加,代码显示错误内容,查看到一下错误

 ini_set('display_errors','yes');
   open_basedir restriction in effect错误解决方法_第2张图片

三、分析错误内容

  查看问题描述以及资料,发现是php open_basedir 配置的问题,php不能引入其授权目录上级及其以上的文件,默认配置在php.ini(/usr/local/php/etc/php.ini),但是我的open_basedir 并没有配置,默认被注释了。

文献说可能在服务器配置目录下,如nginx、Apache等,于是用户sublime打开nginx进行全局搜索,open_base,果真还是搜到了,如下图

   open_basedir restriction in effect错误解决方法_第3张图片

四、修改配置

open_basedir restriction in effect错误解决方法_第4张图片
open_basedir restriction in effect错误解决方法_第5张图片 open_basedir restriction in effect错误解决方法_第6张图片
  line 27 是默认配置,默认配置是nginx.conf root 文件下的权限目录

  line 27 我复制了一行改了授权目录  改成了项目文件夹的上级,重启nginx,项目可以打开了。

open_basedir restriction in effect错误解决方法_第7张图片

五、总结

  就是open_basedir 配置项的文件权限问题,如果你们也遇到了这样的情况,把php.ini 服务器nginx、Apache的配置文件都检查下。

你可能感兴趣的:(php)