Home >Backend Development >PHP Tutorial >Ln建立的软链接文件夹中的文件无法require

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

WBOY
WBOYOriginal
2016-06-06 20:09:141775browse

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

错误提示是:

<code>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 4
Warning: 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 4
Fatal 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</code>

回复内容:

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

错误提示是:

<code>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 4
Warning: 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 4
Fatal 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</code>

先看require报错,估计是文件权限

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

<code>php_admin_value open_basedir /www/web</code>

就可以了。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn