Custom php.ini files

Learn how to use custom php.ini files to control PHP settings for your web site with this guide.

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

🚧

Important

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.

    📘

    Note

    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 File in the File Manager toolbar to create a new file and name it php.ini.

  4. Click on the new file, and then click Edit in the File Manager toolbar to edit the new php.ini.

  5. Add PHP directives to the new php.ini, and then click Save Changes.

  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 hosting.com username:

    lsapi_phpini /home/username/public_html/php.ini
    

More Information

To view a complete list of php.ini directives, please visit http://www.php.net/manual/en/ini.list.php.

Related Articles