Skip to content


How to turn off PHP safe mode and remove open_basedir restrictions to install the Seagull PHP framework on a Media Temple sub domain

Problem

I wanted to run an installation script on a sub-domain of a Dedicated-Virtual server hosted by Media Temple with a Plesk 7.5.4, but received the following php error message when I ran the script:

Warning: file_exists(): open_basedir restriction in effect.

Reason why the error occurs

The reason for this error is because, php safe mode is turned on and because the open_basedir is set for each sub-domain. After quite a lot of searching on the web, I eventually tried a few tutorials, but none of them were comprehensive enough to describe exactly how to solve the actual problem.

Solution

Follow these steps and you should solve the problem:

  1. SSH into your server using the root login information
  2. Once you have logged in, edit the php.ini file located /etc/ folder with a text editor. The line you are looking for is:
    a. Change this line safe_mode = on to safe_mode = off
    b. Or you can cut and paste this one-liner:
    perl -p -i -e ‘s/^safe_mode\s*=\s*on/safe_mode = off/i;’ /etc/php.ini
  3. Make sure that the open_basedir in the php.ini file looks like this:

    ; open_basedir, if set, limits all file operations to the defined
    directory
    ; and below. This directive makes most sense if used in a per-
    directory
    ; or per-virtualhost web server configuration file. This directive is
    ; *NOT* affected by whether Safe Mode is turned On or Off.
    open_basedir = none

  4. Then you need to edit the virtual hosts for the domain and for each sub-domain in the http.inc file, which is located in the /var/www/vhosts/$domain/conf folder.
    Add the following section of code to the domain Virtual Host, as well as to each sub-domain Virtual Host


    < IfModule sapi_apache2.c >
    php_admin_flag engine on
    php_admin_flag safe_mode off
    php_admin_value open_basedir none
    < /IfModule >

    < IfModule mod_php5.c >
    php_admin_flag engine on
    php_admin_flag safe_mode off
    php_admin_value open_basedir none
    < /IfModule >

  5. To complete the process, one needs to type the following two commands:
  6. a. /etc/init.d/httpd stop
    b. /etc/init.d/httpd start

    Hit “Enter� after each command and you should be given an [ OK ] status in the command line.

    Conclusion

    This should solve your problem and if you have any comments, suggestions or improvements, please submit them.

Tags: , , , , .

4 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.

  1. Awesome. I was banging my head against a wall trying to get this working at MT. The piece I was missing what the “http.inc file, which is located in the /var/www/vhosts/$domain/conf folder.”

    A thousand thanks!

  2. SAFAD said

    hi thx for this but can i turn off the safe mode with been a root i meen Client ???

  3. Stephen Blake said

    @SAFD – Not sure that I’m following you here. Do you have root access to the server? If not, then you won’t be able to make the changes required

  4. SAFAD said

    mmmmmmm
    am not root so i cant get the access
    some joomla versions need safemode off

Some HTML is OK

(required)

(required, but never shared)

or, reply to this post via trackback.