How to force reloading php.ini file?

How to force reloading php.ini file?

  1. Blog
  2. 15 November 2026
  3. 3 min read

Stefan Bogdanescu

Founder & Senior Architect

Why PHP Ignores Your php.ini Changes Despite Correct Permissions

When you edit a configuration file expecting immediate results, but the runtime environment still behaves as if nothing changed, it is often disorienting. You have verified the file exists at /opt/rrh/php/lib/php.ini, confirmed that permissions are permissive (-rwxrwxrwx), and even validated that the file parses correctly using PHP's own parse_ini_file() function. Despite restarting the server multiple times, a timezone configuration change simply does not take effect.

This scenario typically points to one specific culprit: the architecture of how the PHP interpreter interacts with Apache on Red Hat Enterprise Linux 6. In this environment, you are running PHP 5.5.19 as an Apache module (libphp5.so). Unlike CGI or FastCGI setups where a single process spawns and dies for every request, Apache modules often load the PHP engine once per worker process. If the initialization sequence of libphp5.so does not explicitly reload the configuration directory upon startup, it may fall back to a hardcoded include path or ignore the file if it cannot determine which one is the "active" version.

The fact that parse_ini_file() works is a crucial diagnostic detail. That function reads the file from the filesystem directly at runtime. It does not care about the configuration directives loaded by the interpreter; it only cares about the raw bytes on disk. The error you are seeing regarding timezone settings confirms that the PHP engine itself has failed to load your specific php.ini during its initialization phase, likely because it is searching for a file in a different default location or using an embedded php.ini shipped with the RPM package that supersedes the one in /opt/rrh/php/lib.

To force PHP to recognize your custom configuration without dropping into complex debugging modes, you must explicitly tell the interpreter which file to use. This is achieved by setting the PHPRC environment variable before the Apache service starts. By doing so, you bypass any internal hardcoded paths and direct the module to load exactly the file you intend.

You can implement this by modifying your system configuration files or using a wrapper script. For instance, adding an export statement in the profile of the user running Apache, or creating a startup script that exports PHPRC before launching the service:

export PHPRC=/opt/rrh/php/lib
service httpd restart

Alternatively, you can set this variable directly within your Apache configuration file using the SetEnv directive. Since you are on Red Hat 6 with a custom installation path, ensure that the php.ini in that directory is not being shadowed by another configuration file named differently but loaded via an alias. Check for files named php-dist.ini, custom.ini, or similar in your default include paths listed in the main php.ini itself (usually found at /etc/php.ini).

Another common pitfall in these legacy Red Hat environments is the presence of multiple PHP versions installed side-by-side. Even though you specified libphp5.so, ensure that Apache isn't dynamically linking to a different version's library that points to a completely different configuration directory. You can verify this by checking the loaded shared objects:

cat /proc/$(pgrep httpd | head -1)/maps | grep libphp5.so

If the module is loading correctly but still ignoring the file, inspect the error_log for messages indicating that a different php.ini was found in a parent directory or that the specific directive you changed (like date.timezone) is commented out in a higher-priority configuration file included before yours.

For modern deployments, managing this complexity is often unnecessary; tools like PHP-FPM allow for easier isolation of configurations per virtual host. However, given your constraints with Apache 2.4 and RHEL 6, explicitly setting the PHPRC environment variable remains the most reliable method to force the interpreter to load your specific php.ini. This approach ensures that subsequent requests will pick up the timezone settings immediately without requiring a full system reboot or service restart beyond a standard Apache reload.

Our network