Plesk open_basedir Fix

I wanted to try and install the Zend Framework on my hosted server today, and I ran into problems.  The Zend Framework suggests that you run a lot of files outside of the httpdocs folder.  But in doing so, you may run into open_basedir restriction problems like I did – and have no clue how to fix it.

I did some searching, found a lot of people suggesting adding little snippets to the php.ini file and the .htaccess file.  I tried all of those and nothing worked.  Later, I was asking around the #zftalk IRC channel and ran into someone that knew exactly how to fix the issue.  So, I wanted to post it for anyone out there hoping to find the solution to this frustrating problem.

Here’s what I was doing:

  1. Setup a subdomain through Plesk
  2. Logged in as root and created the needed directory structure, installed Zend library here:  /var/www/vhosts/
  3. Created my bootstrap file:  /httpdocs/index.php, and the IndexController.php, and the view.

Here’s what you’ve got to do to fix it:

First, create a new file called vhost.conf here:  /var/www/vhosts/YOURDOMAIN.COM/subdomains/YOURSUBDOMAIN/conf/.  When you’ve done that, put in this code, modify it to be what you need, and save it:

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

Now, in order for that to take effect, you’ve got to reconfigure the Plesk vhost.  Open up your terminal, login as root, and enter these commands (modifying it to match what you need):

/usr/local/psa/admin/bin/websrvmng --reconfigure-vhost --vhost-name=YOURDOMAIN.COM

apachectl stop

apachectl start

And that should do it!  I spent an entire Saturday trying to fix this issue.  Hopefully this saves you some time.  (The vhost.conf code – thanks to Daniel and this post)

Keep in mind though, that turning off the open_basedir restrictions for your site does weaken the security slightly, as open_basedir limits the files that can be opened by PHP. If you don’t want to completey remove the open_basedir restrictions, you can re-author the vhost.conf code to open restrictions just to specific directories.

This entry was posted in Apache, Plesk. Bookmark the permalink.

5 Responses to Plesk open_basedir Fix

  1. Pingback: open_basedir restriction in effect and subdomains - Apache Solutions - Developers Q & A

  2. Barbara says:

    Thank you! :)

  3. ted says:

    i tryed all sorts of things to remove the open base directory issues for subdomains to access content from my main domain in plesk and nothing else worked apart from this

    great post, very usefull info, now i just have to add it to my other 30 odd subdomains