Ways to enable php safe_mode
When using PHP as an Apache module, you can also change the configuration settings using directives in Apache configuration files (e.g. httpd.conf) ,php.ini file and .htaccess files.
Activate/deactivate Safe Mode Globally
It is very simple to active safe mode on the entire server. All you need to do is just edit the php.ini file. If you can’t find where php.ini is or have multiple copies on your server the best thing to do is run follwing command on shell .
#php -i |grep php.ini
A few lines down you’ll see this:
Configuration File (php.ini) Path: /usr/local/Zend/etc/php.ini or /etc/php.ini
1) Open up php.ini .
vi /path to php/php.ini (replace with the path to your php.ini file)
2) Find the following line: safe_mode
3) Turning safe mode on or off.
safe_mode = Off
You may active it by or turn it off by changing it to either On OR Off.
safe_mode = On
4) Restart the Apache web server by
/etc/init.d/httpd restart or Kill all exiting httpd connection and run
service httpd startssl
Activate/deactivate Safe Mode Using Per Site Basis ie.Activate/deactivate Safe Mode locally
There are some applications or scripts that require safe_mode off like Modernbill , gallary, etc, or any other scripts doesn’t work well with safe_mode.So it is not well to diable safe_mode on the entire server just for these application or scripts for this condtion you can disable php safe mode locally i.e for that particular site or account only.
There are two way to do this
A] In httpd.conf file
1] Then find the httpd.conf, normally it’s in /etc/httpd/conf/ or /usr/local/apache/conf/
2) Then find the Site you wish to edit.
You should see virtualhost configuration of that Site
ServerAlias
www.domain.net domain.net
ServerAdmin
[email protected]
DocumentRoot /home/domain/public_html
BytesLog domlogs/domain.net-bytes_log
ServerName
www.domain.net
User domain
Group domain
CustomLog domlogs/domain.net combined
ScriptAlias /cgi-bin/ /home/domain/public_html/cgi-bin/
3) Now add this line:
php_admin_flag safe_mode Off
Or
php_admin_value safe_mode 0
4] Save the file and Restart the Apache web server by
B] .htaccess file
1]Find the .htaccess file under public_html folder or that particular application ,scripts folder of that site if it is not present then create .htaccess file
# vi .htaccess
2] Insert this line into your .htaccess file:
php_admin_flag safe_mode Off
Or
php_admin_value safe_mode 0
Note::
There are several Apache directives that allow you to change the PHP configuration from within the Apache configuration file itself.
php_value name value
This sets the value of the specified variable.
php_flag name on|off
This is used to set a Boolean configuration option.
php_admin_value name value
This sets the value of the specified variable. “Admin” configuration settings can only be set from within the main Apache configuration files, and not from .htaccess files.
php_admin_flag name on|off
