PHP Configuration Files Are Not Inherited

PHP Configuration Files Are Not Inherited
I had a problem that started a couple days ago on one of my sites, where my custom php.ini file wasn’t overriding the server’s global php.ini file. This meant that certain directives weren’t set and one of my scripts wasn’t behaving.

In the back and forth with my web host, after getting someone knowledgable about the issue, I discovered that subdirectories in a site structure do not inherit the php.ini file above them. This was news to me (and it may be peculiar to sites running suPHP); I had simply assumed that any script on a site would be subject to the php.ini in the home directory or the web root. I don’t deal frequently with the file, so this had never come up before.

There are two ways around this issue. The first is to create additional php.ini files in each subdirectory that has scripts that are executed or included. This could be time-consuming and you run the risk of overlooking a directory.

The second is to include this directive (pointing to the actual directory containing php.ini) in .htaccess, which will cause the php.ini to be inherited by subfolders:

suPHP_ConfigPath /home/username/public_html

For more information, you may want to peruse this article.