realpath() open_basedir restriction in effect.

纵然是瞬间 提交于 2019-12-12 03:48:26

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!