Shiki

I'm so bad with words that I can't even make a cool tagline

Adding allowed open_basedir paths in a MediaTemple DV

This is a quick fix for PHP errors like these on a Media Temple DV:

Warning: include_once() [function.include-once]: open_basedir restriction in effect. 

I got this a few days ago when trying to setup an app. There are instructions in Media Temple’s site on how to fix this but this set of steps is what worked for me.

  1. Edit or create a vhost.conf file inside this folder: /var/www/vhosts/YOURDOMAIN.COM/conf/. Replace YOURDOMAIN.COM with the domain you wish to configure.
  2. Add this in vhost.conf:

    <Directory /var/www/vhosts/YOURDOMAIN.COM/httpdocs>
      <IfModule sapi_apache2.c>
        php_admin_value open_basedir "/var/www/vhosts/YOURDOMAIN.COM/httpdocs:/tmp:/ADDITIONAL/PATH"
      </IfModule>
      <IfModule mod_php5.c>
        php_admin_value open_basedir "/var/www/vhosts/YOURDOMAIN.COM/httpdocs:/tmp:/ADDITIONAL/PATH"
      </IfModule>
    </Directory>
    

    Replace /ADDITIONAL/PATH with a path you want added to the open_basedir whitelist. You can add more, just separate them with colons (:).

  3. Reconfigure the webserver so vhost.conf will be applied.

    /usr/local/psa/admin/sbin/httpdmng --reconfigure-domain YOURDOMAIN.COM
    
  4. Restart Apache

    /etc/init.d/httpd restart
    
  5. Done! Check the value of open_basedir in phpinfo() to see if it worked.

8 Responses to Adding allowed open_basedir paths in a MediaTemple DV

I keep trying to attempt this on my media temple server for a client, and I get the error that I can’t even open the /conf folder. Clearly a permissions issue, but is this something I can bypass in mediatemple/plesk?

Thanks, -Chris.

Yep, I think it is a permission error. I was using root (SSH) when I accessed it. I haven’t tried doing this inside Plesk though, sorry.

Managed to get SSH access from the client, and I’m still stuck though, because it appears the httpdmng command isn’t available to me. Thank you for your help, regardless. -Chris.

That worked. Thank you. I didn’t solve my problem, but likely that was because I have the incorrect path set. Clearly I don’t spend enough time on the server configurations! I’ll keep messing around with it.

Thank you very much, Shiki.

Hey guys, I rarely ever post anything, but this issue was kicking my A** for about a week until I solved it! Seems that all the post I read were not explained properly. The above led me to the right track, but I have a little different setup, as I’m running a few domains on my server and only wanted to add a new path for one file that was giving an issue. Many of the other tutorials were way off for my needs, so I hope this helps someone. The problem was Jomsocials wordfilter.php not in the tmp path so the profile page showed the ugly warning. I simply used winscp program to login as root via sftp option. You can use ftp, but I like to be safe. From there, I navigated to the path where the httpd.includes file is > /var/www/vhosts/yourdomain.com/conf Open the file and add the info.

Here is the entire line of code that will be added for php 4 and php 5. Use the quotes on the ends and separate the second path with a colon and no spaces. As you can see, there are 2 paths in the below code, with the second starting after /tmp. The original path ended like this httpdocs:/tmp” so to add new path remove quotes and replace with colon and so forth, ending with the quotes. “/var/www/vhosts/yourdomain.com/httpdocs:/tmp:/var/www/vhosts/yourdomain.com/httpdocs:/plugins/community/wordfilter.php”

Go into plesk if you have it and stop and restart apache and you should be good to go, or use the ssh command above if it will work for you. Hope this helps someone and saves your a week.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

*


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>