我怎么能放松PHP的open

我怎么能放松PHP的open

本文介绍了我怎么能放松PHP的open_basedir的限制?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可以由PHP目录树中打开的文件。

我存储多级库和配置文件我的网站根目录之外。这样,Web服务器并不能让他们公开访问。然而,当我试图从我的应用程序包括他们,我​​得到了open_basedir限制,错误是这样的:

My web root is here:

/var/www/vhosts/domain.tld/httpdocs

My libraries and configuration directory are here:

/var/www/vhosts/domain.tld/zend

What would be the best workaround to relax the open_basedir restriction so that the the directory tree under the domain folder becomes available to my application? I have a number of domains that I want to do this with, and I'm also obviously wary of creating security vulnerabilities.

Note: I am using CentOS, Apache, Plesk, and I have root ssh access to the server. And though this doesn't apply to Zend Framework directly, I am using it in this instance. So here is the inclusion from Zend's bootstrap:

define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../zend/application/'));
set_include_path(APPLICATION_PATH . '/../zend/library' . PATH_SEPARATOR . get_include_path());
解决方案

You can also do this easily on a per-directory basis using the Apache (assuming this is your web server) configuration file (e.g. httpd.conf)

<Directory /var/www/vhosts/domain.tld/httpdocs>
php_admin_value open_basedir "/var/www/vhosts/domain.tld/httpdocs:/var/www/vhosts/domain.tld/zend"
</Directory>

you can also completely remove the restriction with

<Directory /var/www/vhosts/domain.tld/httpdocs>
php_admin_value open_basedir none
</Directory>

这篇关于我怎么能放松PHP的open_basedir的限制?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 08:48