HostGator.com » Support Portal



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 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.

Making Changes - Best Practices

It is best if you have a copy of the default php.ini file in your cPanel Home directory (/home/username/) and then make changes to that file. (See below for file location for Plesk.)

If you need a php.ini file for your account, please contact us via phone or live chat. We are glad to create a complete file for you.

Location of custom php.ini

The copy of the default php.ini file would need to be located in the following location:

  • cPanel: /home/username/php.ini
  • Plesk for VPS: /var/www/vhost/$DOMAIN/etc/php.ini

Be sure to replace "username" with your actual cPanel user name, and "$DOMAIN" with your actual domain.

Making Changes via cPanel's php.ini QuickConfig

You can also make changes to php.ini via the "php.ini QuickConfig" utility in the "Software/Services" section of your cPanel.

  1. Login to cPanel.
  2. Click on php.ini QuickConfig in the "Software/Services" section.
  3. Enable QuickConfig if not already enabled.
  4. Change the settings that you want to change.
  5. Click the Save Changes button to save your changes.
WARNING: Changes you make here may overwrite the current PHP settings on your account (as contained in your existing php.ini file).

Making Changes - Alternate Method for cPanel

Instead of having us create and setup the php.ini file for you, you can place your php.ini file in your Home Directory (/home/username/) yourself and then add this code to your primary .htaccess (/home/username/public_html/.htaccess).

Be sure to replace "username" with your actual cPanel user name.

Note: While it is possible to just create a php.ini file with the changes you like added to it, the more advisable practice would be to modify an existing / default php.ini file to suit your needs.

<IfModule mod_suphp.c>
suPHP_ConfigPath /home/username
<Files php.ini>
order allow,deny
deny from all
</Files>
</IfModule>

Some common changes that you must make when moving from non-secure php environment to suPHP:

For example, if your site had these settings in a .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 nor 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.

Article Comments

Mogens
Please add a link to doc which explains where you can find the php.ini file

HostGator
It does not already exist. You must create your own from scratch.

Alternatively, you can contact HostGator and we will create this file for you.

plugnplay
If I create a site specific php.ini, that works fine but then I find that extensions that are loaded in the server php.ini (eg IonCube Decoder and APC) no longer get loaded for the site. You can copy the full file from /usr/local/lib/php.ini to your site but that doesn't seem to be a very good approach, as it will miss future server level adjustments.

HostGator
That is a great reason to get a copy of the php.ini from HostGator and adjust only the settings needed.

Anthony
1. What happens if i do not have a php.ini file? Do i need one if I do not plan on making changes to the php settings?

2. According to the php.ini sample settings you provided above... Can I just have a php.ini file with those settings as the only content in the file? Meaning would the php revert to server settings for anything not listed in our custom made file?

I plan on getting a reseller account and curious if I can just do the above or if I will need to contact you every time a client needs a php.ini file?

HostGator
1. Nothing will happen; you do not need to create a php.ini file unless you want to control the settings.

2. Yes, you can create a php.ini file with just the lines you want to control, and the other settings will use the HostGator default values.

HostGator
Thank you for your comments. Just a quick reminder that the comments on this page are not monitored by technical support staff, and that for support issues, it is best to contact us by live chat, phone or email so we can assist you right away.

Although comments are not monitored by technical support staff, they are moderated and read by technical writers. Comments will need to be approved by a moderator before appearing.

Our technical writers do read the comments periodically for the purposes of updating the articles, and do appreciate your feedback, suggestions and corrections to the articles themselves, as well as any suggestions or tips for readers of this article. However, support questions posted here are not guaranteed to be replied to in a timely manner or at all. For support issues, it is best to contact our support staff instead by live chat, email or phone.



Your comments help us keep the knowledge base updated. This is not a medium for support. If you have questions or need help, please contact us via email, phone or live chat for fast assistance.

Post Comment