I was working on a client site today that required me to create a custom php.ini file so that I was able to enable some PHP functions that were disabled by default by their hosting provider. While I was doing this, it got me thinking that I should give you all a heads up about about why you should be cautious when using a custom php.ini file.
In my article “So You Want A Larger Upload Limit Eh…” I walk you through the process of creating a custom php.ini file so that you could modify the upload limit for your server; essentially overriding the default values set by your hosting provider. Your custom php.ini file is a copy, originally based on the php.ini file installed as part of your server’s setup for its default PHP version, and as such, you could run into serious problems if you decide to use another PHP version.
The reason for this being that your custom php.ini copy may contain configuration paths, extensions and other settings that are not suitable for a PHP version that gets chosen down the line. It’s even possible it could be missing settings required by the new PHP version entirely. That would not be good!
An example of problems that can arise between PHP version changes is as follows:
PHP 5.2: extension_dir=”/usr/local/lib/php/extensions/no-debug-non-zts-20060613″
PHP 5.3: extension_dir=”/opt/php53/lib/php/extensions/no-debug-non-zts-20090626″
Notice in the above example that the server path that is used for extension modules is different between PHP 5.2 and PHP 5.3.
If you are working with a custom php.ini copy to modify your hosts default PHP configurations, make a note of any modifications that you have made and then delete the custom php.ini copy you created along with it’s corresponding suPHP_ConfigPath pointer (if applicable, not all servers require this portion), located in your primary .htaccess file prior to implementing a PHP version change!