首页 > 开发 > linux > 正文

Ln建立的软链接文件夹中的文件无法require

2017-09-11 20:20:26  来源: 网友分享

一个网站中的文件夹要在同服务器的另一个网站中有用到,不想来回复制麻烦,试着用ln -s命令在另一个网站项目下生成软链接,然后发现无法require。自己阿里云上测试一下却可以,请问是怎么回事?

错误提示是:

Warning: require_once(): open_basedir restriction in effect. File(/www/web/jyamd/system/db_config.php) is not within the allowed path(s): (/www/web/jycf:/tmp) in /www/web/jycf/public/test.php on line 4Warning: require_once(/www/web/jyamd/system/db_config.php): failed to open stream: Operation not permitted in /www/web/jycf/public/test.php on line 4Fatal error: require_once(): Failed opening required '../system/db_config.php' (include_path='.:/www/wdlinux/apache_php-5.4.26/lib/php') in /www/web/jycf/public/test.php on line 4

解决方案

自己解决了,出错的原因是我们用了虚拟主机管理软件WDCP,这个软件在网站的vhosts.conf里自动加了目录限制。
找到网站的这一段,把目录限制改为:

php_admin_value open_basedir /www/web

就可以了。