问题
I'm trying to get my Zend Framework application up and running on my VPS. I'm receiving this error:
Error
Warning: realpath() [function.realpath]: open_basedir restriction in effect.
Apparently this is quite common with Plesk's default restrictions so I'm sure some of you have faced the same problem.
What I've tried
In /var/www/vhosts/DOMAIN/conf/ I have created the file vhost.conf using the Virtuozzo Power Panel. Below is the code that I placed in vhost.conf:
Attempt 1
<Directory /var/www/vhosts/DOMAIN/public>
<IfModule sapi_apache2.c>
php_admin_value open_basedir none
</IfModule>
<IfModule mod_php5.c>
php_admin_value open_basedir none
</IfModule>
</Directory>
Attempt 2
<Directory /var/www/vhosts/DOMAIN/public>
php_admin_value open_basedir none
</Directory>
I've also restarted the httpd service.
Folder structure
My folder structure is as follows:
/var/www/vhosts/DOMAIN/application
/var/www/vhosts/DOMAIN/library
/var/www/vhosts/DOMAIN/public
Any help would be much appreciated.
回答1:
I think that you need to set the open_basedir
for the entire project:
<Directory /var/www/vhosts/DOMAIN>
php_admin_value open_basedir none
</Directory>
You will also need to set the DocumentRoot
to:
DocumentRoot "/var/www/vhosts/DOMAIN/public"
though.
回答2:
I had the same problem & solved it without setting open_basedir to none. You can add multiple paths to open_basedir by separating them with ":" in Linux and ";" in Windows. So if "realpath" is mentioned in your warning add "realpath" to your open_basedir setting or a parent directory of "realpath". For example like that:
php_admin_value open_basedir "/srv/www/vhosts/domain.com/httpdocs:/tmp:/usr/share/php5/"
Now your open_basedir is configured with 3 paths:
/srv/www/vhosts/domain.com/httpdocs
/tmp
/usr/share/php5
In my case the last path of the 3 above was needed for zend to run on my system without warnings.
Also notice that there is a difference between ending your path with "/" or not ! Without the "/" all subfolders will be included to open_basedir. Take a look here: http://www.php.net/manual/en/ini.core.php#ini.open-basedir
Lucian
来源:https://stackoverflow.com/questions/10262104/realpath-open-basedir-restriction-in-effect