How to turn off PHP safe mode and remove open_basedir restrictions to install the Seagull PHP framework on a Media Temple sub domain
April 3rd, 2007 by Stephen BlakeProblem
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:
- SSH into your server using the root login information
- 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 - 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 - 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 >
- To complete the process, one needs to type the following two commands:
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.


November 29th, 2007 at 4:30 am
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!