Use a Custom PHP.ini File
What is php.ini?
The php.ini file is where you declare changes to your PHP settings. You can use the default settings for the server, change specific settings by editing the existing php.ini, or create a new text file and name it php.ini.
There are several instances that may require you to modify a setting in the php.ini file for your website, such as increasing the PHP upload limit. We definitely permit the use of a custom php.ini file, but there are some requirements involved just to ensure that the files work as expected.
The server is already configured with standard settings for PHP that have been selected by our administrators to be the most optimal setting for a majority of our customers. Unless you specifically need to change one or more of the settings, there is no need to create or modify a php.ini file. If the php.ini file does not exist in your account, then your site will use the default PHP settings defined on the server.
Why create a custom php.ini file?
Some examples of what may be changed by using a custom php.ini file are:
Editing the maximum size of a file that can be uploaded in a PHP script (upload_max_filesize = 10M)
Editing the maximum PHP post size which must at least match upload_max_filesize (post_max_size = 10M)
Editing the maximum file execution time in seconds (max_execution_time = 30)
Discover the Handler
Before a custom PHP directive can be set, the PHP handler needs to be determined, so that the correct method can be used. To find out your PHP handler:
Log into shell as root
Check the file '/etc/httpd/conf/php.conf'
If you see the line 'LoadModule suphp_module modules/mod_suphp.so' then you are using suPHP.
If you see the line 'LoadModule php5_module modules/libphp5.so' then you are not using suPHP, and can use the DSO instructions.
Please see each set of instructions below.
Create a PHP.ini in cPanel
This file should be created in your cPanel Home directory (/home/username/). Be sure to replace 'username' with your actual cPanel user name, and '$DOMAIN' with your actual domain.
Log into cPanel
From the Files section, click File Manager
Select Home Directory from the available options and click Go
Click New File, at the top of the page
In the New File Name field enter 'php.ini' and click Create New File
Click the file named php.ini
Click Edit at the top of the page, and then click Edit from the popup box
Now you can input the contents of your php.ini file and click Save.
Create Custom PHP.ini with suPHP
To begin creating your very own custom php.ini file:
Copy your php.ini file in your cPanel user home directory, 'cp /usr/local/lib/php.ini /home/user/' (where 'user' is your cPanel username)
Create a .htaccess file inside the 'public_html' directory of your site OR edit the existing .htaccess file, if one exists, by adding the following line:
Note: you do not need to add 'php.ini' to the end of it.
Once you have completed the above steps your php.ini file will be active. You will now be able to make edits to the custom php.ini. Your edits will only affect directories below the .htaccess file in which you referenced the file.
Create Custom PHP.ini with DSO
On the DSO server, directives should be placed in the .htaccess file for the directory to which they should apply. In most cases, this will be '/home/user/public_html/ where 'user' is your cPanel username.
To edit a boolean value (on/off) you can use php_flag like this:
php_flag magic_quotes_gpc off
To edit a numeric value you can use php_value like this:
php_value memory_limit 256M
Should you require any further assistance with creating a custom php.ini file then check with one of our fantastic Support people.