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

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

WBOY
Release: 2016-06-06 20:09:14
Original
1784 people have browsed it

一个网站中的文件夹要在同服务器的另一个网站中有用到,不想来回复制麻烦,试着用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>
Copy after login
Copy after login

回复内容:

一个网站中的文件夹要在同服务器的另一个网站中有用到,不想来回复制麻烦,试着用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>
Copy after login
Copy after login

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

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

<code>php_admin_value open_basedir /www/web</code>
Copy after login

就可以了。

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template