我需要在 Plesk 10 上允许 vhost 子域的包含路径。我已将 PHP PEAR 路径编辑到 /etc/php.ini 中,因为我很高兴它可以全局使用:
include_path = ".:/usr/share/pear/"
只要脚本尝试包含该目录中的文件,PHP 就能够看到这些文件,这种方法是可行的,但我收到了可怕的 openbasedir 错误:
Warning: require_once() [function.require-once]: open_basedir restriction in effect. File(/usr/share/pear/xxxx.php) is not within the allowed path(s): (/var/www/vhosts/xxxx.com/subdomains/test/httpdocs/:/tmp/)
我说的对吗?子域或主域可以有一个 vhost.conf 文件,我可以在该文件中更改 openbasedir 允许的路径?我试过寻找解决方案,但恐怕我还找不到 :)
答案1
啊,找到了!
1)为子域创建 vhost.conf:/var/www/vhosts/xxxx.com/subdomains/test/conf/vhost.conf
2)添加以下内容:
<Directory /var/www/vhosts/xxxx.com/subdomains/test/httpdocs>
<IfModule sapi_apache2.c>
php_admin_value open_basedir "/var/www/vhosts/xxxx.com/subdomains/test/httpdocs:/tmp:/usr/share/pear"
</IfModule>
<IfModule mod_php5.c>
php_admin_value open_basedir "/var/www/vhosts/xxxx.com/subdomains/test/httpdocs:/tmp:/usr/share/pear"
</IfModule>
</Directory>
3)配置 plesk 以识别新的 vhost.conf
/usr/local/psa/admin/sbin/httpdmng --reconfigure-domain test.xxxx.com
4)重新启动apache
service httpd restart