Search code examples
phpconfigurationsafe-mode

PHP stuck in safe_mode


Even though I've set

safe_mode = Off

in php.ini, restarted apache, and even rebooted the system...

when I try to execute set_time_limit(0) in my application, it throws the warning that set_time_limit cannot be st in safe mode.

This has been erratic behavior; earlier when I set safe_mode to Off, the system worked fine. But later on, seemingly autonomously, safe_mode has returned, and my application breaks due to the time_limit.

Is there anything I can check? I fear that my system has been compromised.


Solution

  • PHP settings can appear in a number of different locations - it's likely that the setting in php.ini is being overridden by a setting elsewhere.

    You might want to check:

    • Your Apache configuration, such as httpd.conf/apache.conf or virtual host configuration.
    • An .htaccess file

    Given that phpinfo is talking about a "Local setting" that sounds a little bit like a .htaccess setting to me but it could be in another part of Apache's config.

    It's not usual for PHP to be placed in safe mode on a 'default install', indeed it will be deprecated in future PHP versions if it isn't already. It's strange then that you have safe mode enabled without knowing it - perhaps some other app enabled it as part of its install script or maybe you copy-pasted some example configuration from somewhere? I dunno.