Getting around open_basedir restriction on Plesk

Almost every time I do a deploy on Plesk-based hosting server, I hit the same roadblock:

PHP Warning:  realpath() [<a href='function.realpath'>function.realpath</a>]: open_basedir restriction in effect.

Since I tend to keep my app-code outside of webroot, this restriction is somewhat a problem. Well, luckily, the fix is simple enough.

1. Add file vhost.conf to /var/www/vhosts/YOURDOMAIN/conf folder with the following:

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

2. Reload server configuration, either via Plesk admin or through CLI:

/usr/local/psa/admin/sbin/websrvmng -u --vhost-name=yourdomain