出于安全考虑,我将yii
文件夹放在html根目录下面,所以我的结构看起来像这样
/conf
/httpdocs
/httpsdocs
/yii
在运行网站时,我收到一个错误open_basedir限制,yii.php
从index.php
调用的httpdocs
不在允许的路径中。由于此网站是子域,我是否可以编辑主域或子域的vhosts.conf
?
允许适当的设置是什么
/var/www/vhosts/example.com/subdomains/mysubdomain/yii
可以访问的路径?
修改
所以我的/var/www/vhosts/example.com/conf/vhost.conf
文件现在看起来像这样:
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服务器,但我仍然收到错误:
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
答案 0 :(得分:1)
在虚拟主机中:
php_admin_value open_basedir ".:/var/www/vhosts/example.com/subdomains/mysubdomain/httpdocs:/my/own/tmp:/var/www/vhosts/example.com/subdomains/mysubdomain/yii"
答案 1 :(得分:0)
我找到了答案。您必须指定不同的模块,否则只需编辑vhost文件就不会产生太大影响。这是关闭open_basedir但你可以相应地编辑设置。
<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/