Controlling PHP settings with a custom php.ini file

This article describes how to use custom php.ini files to control PHP settings for your web site.

This article applies to non-Turbo managed hosting packages with the cPanel management interface. For Turbo hosting packages, please see this article.

Setting up a custom php.ini file

A php.ini file contains directives for controlling many PHP settings. You can set up one or multiple custom php.ini files to define how your web site functions. For example, you might have a custom file in your /home/username/public_html directory for your web site's main pages, and a separate custom file in your /home/username/public_html/images directory for your web site's image files.


To set up a custom php.ini file, follow these steps:

  1. Log in to cPanel.
    If you do not know how to log in to your cPanel account, please see this article.
  2. Using the File Manager, navigate to the directory where you want to modify the behavior of php. By default, a custom php.ini affects only the directory where it is located. 
  3. Click the File button in the File Manager toolbar to create a new file and name it php.ini.
  4. Click on the new file and then click the Edit button in the File Manager toolbar to edit the new php.ini.
  5. Add php directives to the new php.ini and then click the Save Changes button.
  6. After you create the php.ini file and set its permissions, you can verify that the configuration is active. To do this, create a phpinfo file in the directory where you created the php.ini
  7. Load the phpinfo file in your web browser, and locate one of the directives you set. Make sure the changes are shown.
  8. You can create custom php.ini files for each directory in your web site, but many people configure settings in one php.ini file and then apply it to the entire web site. To do this, add the following line to the .htaccess file in your web site's document root directory. Replace username with your A2 Hosting username:
    lsapi_phpini /home/username/public_html/php.ini

More Information

To view a complete list of php.ini directives, please visit

Get PHP Hosting

Article Details

  • Level: Intermediate

Did you find this article helpful? Then you'll love our support. Experience the A2 Hosting difference today and get a pre-secured, pre-optimized website. Check out our web hosting plans today.

We use cookies to personalize the website for you and to analyze the use of our website. You consent to this by clicking on "I consent" or by continuing your use of this website. Further information about cookies can be found in our Privacy Policy.