Edit PHP Safe Mode on a DV Server


Browse by products and services

  • Applies to: DV
    • Difficulty: Easy
    • Time: 10
    • Tools needed: SSH
  • Applies to: DV 4.0
    • Difficulty: Easy
    • Time: 10
    • Tools needed: SSH

For a discussion of Safe Mode and security, please see PHP Safe Mode, Problems, and Workarounds first.

Disable Safe Mode Globally in SSH

You can edit your php.ini file to disable Safe Mode for all domains.

    1. Log into your server as a root or sudo user via SSH.
    2. Open your php.ini file for editing.
vi /etc/php.ini
    1. Edit this line, from On to Off.

Filename: php.ini

safe_mode = On
    1. Change to Off.

Filename: php.ini

safe_mode = Off

vi tip

Type "/" and a search string then hit enter to search for a particular phrase in a long file. Press "i" to enter "insert mode" so you can type and copy/paste. Press "Esc" to exit "insert mode" when you are done modifying the file. Type ":wq" to save and quit.

    1. Restart Apache.
/etc/init.d/httpd restart

One-line Alternate Method

    1. Log into your server as a root or sudo user via SSH.
    2. Execute the following command.
perl -p -i -e 's/^safe_mode\s*=\s*on/safe_mode =off/i;' /etc/php.ini
    1. Restart Apache.
/etc/init.d/httpd restart

Disable/Enable Safe Mode for Individual Domains in Plesk

  1. Sign into Plesk.
  2. Select the domain to edit.
  3. (a) If you are using Service Provider Mode Interface (you have left navigation), then under Server Management, select Tools & Settings.
    tools_settings

    (b) If you are using the Power User Mode Interface, select Hosting Settings
    hosting_settings

    Select the tab labeled Server.
    server_tab
    This will provide a list of Tools & Settings.  
  4. Under Panel, select Custom View Settings.
    custom_view
  5. Select the tab labeled PHP Settings.
    php_tab
  6. Under the section Common Settings, toggle safe_mode between off and on.
    safe_mode
  7. Click OK.

Test

You can verify that safe mode is off on your phpinfo.php page.