open_basedir 在效果和子域中的限制 [英] open_basedir restriction in effect and subdomains

查看:21
本文介绍了open_basedir 在效果和子域中的限制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

出于安全原因,我将 yii 文件夹放在 html 根目录下,所以我的结构如下

For security reasons I have put my yii folder below the html root, so my structure looks like this

/conf
/httpdocs
/httpsdocs
/yii

运行网站时,我收到一个错误 open_basedir 限制,实际上是 yii.phpindex.phphttpdocs 调用不在允许的路径中.因为这个站点是一个子域,我应该编辑主域或子域的 vhosts.conf 吗?

when running the site I get an error open_basedir restriction in effect that yii.php which is called by index.php out of httpdocs is not in the allowed path. Because this site is a subdomain do I edit the vhosts.conf of the main domain or of the subdomain?

允许的正确设置是什么

/var/www/vhosts/example.com/subdomains/mysubdomain/yii 

访问路径?

编辑

所以我的 /var/www/vhosts/example.com/conf/vhost.conf 文件现在看起来像这样:

So my /var/www/vhosts/example.com/conf/vhost.conf file looks like this now:

AddHandler fcgid-script .php
<Directory /var/www/vhosts/example.com/httpdocs>
php_admin_value open_basedir ".:/var/www/vhosts/example.com/subdomains/mysubdomain/httpdocs:/tmp/:/var/www/vhosts/example.com/subdomains/mysubdomain/yii"
FCGIWrapper /var/www/vhosts/example.com/bin/php-cgi .php
Options +ExecCGI +FollowSymLinks
allow from all
</Directory>

我已经重新配置并重新启动了 Web 服务器,但仍然出现错误:

I've reconfigured and restarted the web server but I still get the error:

Warning: require_once() [function.require-once]: open_basedir restriction in effect. 
File(/var/www/vhosts/example.com/subdomains/mysubdomain/httpdocs/../yii/yii.php) is not within the allowed path(s): 
(/var/www/vhosts/example.com/subdomains/mysubdomain/httpdocs:/tmp) 
in /var/www/vhosts/example.com/subdomains/mysubdomain/httpdocs/index.php on line 26

推荐答案

我找到了答案.您必须指定不同的模块,否则简单地编辑 vhost 文件不会产生太大影响.这是关闭 open_basedir 但您可以相应地编辑设置.

I found the answer. You have to specify the different modules or else simply editing the vhost file doens't have much of an effect. This is to turn off the open_basedir but you can edit the settings accordingly.

<Directory /var/www/vhosts/YOURDOMAIN.COM/subdomains/YOUSUBDOMAIN/httpdocs>
  <IfModule sapi_apache2.c>
  php_admin_value open_basedir none
</IfModule>
<IfModule mod_php5.c>
  php_admin_value open_basedir none
  </IfModule>
</Directory>

然后

# /usr/local/psa/admin/bin/websrvmng --reconfigure-vhost --vhost-name=YOURDOMAIN.COM
# apachectl stop
# apachectl start

完整文章可以在这里找到:http://prattski.com/2008/09/13/plesk-open_basedir-fix/

Full article can be found here: http://prattski.com/2008/09/13/plesk-open_basedir-fix/

这篇关于open_basedir 在效果和子域中的限制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆