What is php.ini?
The php.ini file and changing PHP Settings
The php.ini file is a special file for PHP and various flavors such as suPHP (pronounced sue-p-h-p).
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.
The server is already configured with standard settings for PHP which your site will use by default. Unless you need to change one or more of the settings, there is no need to create or modify a php.ini file.
Create a php.ini File
This file should be created in your cPanel Home directory (
/home/username/). For VPS Plesk users the file should already exist in the following directory:
Be sure to replace "username" with your actual cPanel user name, and "$DOMAIN" with your actual domain.
How to create a new php.ini file in cPanel:
- Login to cPanel.
- In the Files section, click on the File Manager icon.
- Select Home Directory and click Go.
- Click the New File button at the top of the page.
- In the field called New File Name, enter php.ini and click Create New File.
- Click the file named php.ini.
- Select the Edit button at the top of the page and click the Edit button in the pop-up box.
You can now input the contents of your php.ini file and click save. For a complete set of default php.ini files for PHP versions 5.5 through 7.0 click the link below:
Default php.ini Files
Use the links below to navigate to an article with the full php.ini code for the PHP version used on your account. If you are unsure of what PHP version your site is running, you can use the phpinfo function to locate the correct version.
Making Changes Global
Now that you have an accessible php.ini file you can use the code provided within this section to make the file global for your entire account. This is done by using the SuPHP handler, which designates what php.ini file to execute.
The following code should be placed at the top of your .htaccess file inside the public_html folder.
Be sure to replace "username" with your actual cPanel user name.
<IfModule mod_suphp.c> suPHP_ConfigPath /home/username <Files php.ini> order allow,deny deny from all </Files> </IfModule>
After the above steps have been completed you can review your settings and confirm your configuration path by utilizing the phpinfo function. For more information on how to use this function, please refer to the following article:
Moving to suPHP
Some common changes must be made when moving from non-secure php environment to suPHP. For example, if your site had these settings in the .htaccess file:
php_flag upload_max_filesize 10M php_value post_max_size 10M php_value max_execution_time 30
SuExec users must put them in a php.ini file instead. Here is the proper syntax:
upload_max_filesize = 10M post_max_size = 10M max_execution_time = 30