How to change PHP settings with a php.ini
NOTE: This is for use with servers not using CloudLinux w/ PHP Selector. If your server is using CloudLinux w/ PHP Selector, please refer to the instructions here: How to configure PHP.
This article shows you how to customize the php configuration using a php.ini file to modify php configurations for your script. You can change any of the PHP settings that are configured on the server by using a custom php.ini file. All you need to do is create a text document entitled:
php.ini
Within this text document, specify the setting(s) you're wanting to change on separate lines. Here are some examples of PHP settings that you can change:
<syntaxhighlight lang="bash">register_globals = Off memory_limit = 64M</syntaxhighlight>
You will then need to set the permissions of the file to '755' and place it within the executing script's directory (the same directory that your script is located that requires this setting) because php.ini files are not recursive. If you're wanting to make your custom php.ini file recursive, in which it will affect all of your account's web accessible directories, you can view details on how to do so here:
How to make a php.ini file apply to all subdirectories
You can verify that the settings you specified have taken effect by creating a text document entitled:
phpinfo.php
with the following specified within it:
<syntaxhighlight lang="bash"><? phpinfo(); ?></syntaxhighlight>
You will then upload the 'phpinfo.php' file to the same directory you uploaded the 'php.ini' file to and view the 'phpinfo.php' file in your internet browser.