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.

Default Settings

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:

  • /var/www/vhost/$DOMAIN/etc/php.ini

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:

  1. Login to cPanel.
  2. In the Files section, click on the File Manager icon.
  3. Select Home Directory and click Go.
  4. Click the New File button at the top of the page.
  5. In the field called New File Name, enter php.ini and click Create New File.
  6. Click the file named php.ini.
  7. 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.

Note: HostGator discourages the use of PHP versions which no longer receive security updates, and while they may be present on some servers, the ini files for these versions are not provided here.
  • PHP 5.5
  • PHP 5.6
  • PHP 7.0
If you need assistance creating a php.ini file for your account, please contact us via phone or live chat


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.

Note: If this step is not completed, the changes made within the custom php.ini file will not take effect and the file will not be referenced when your site is accessed.

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

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:

  • phpinfo

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


Note: HostGator cannot know why you want or need to change these settings. You are changing this at the advice of your web designer or the developer of your script. HostGator can only show you where to make the change.
  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

PHP 5.5 Full php.ini Text

The full text used for the PHP 5.5 php.ini file is below.  [PHP] ;;;;;;;;;;; ; WARNING ;...

PHP 5.6 Full php.ini Text

The full text used for the PHP 5.6 php.ini file is below. [PHP] ;;;;;;;;;;; ; WARNING ;...

PHP 7.0 Full php.ini Text

The full text used for the PHP 7.0 php.ini file is below. [PHP] ;;;;;;;;;;;;;;;;;;; ;...

Powered by WHMCompleteSolution