Controlling PHP settings with a custom php.ini file

Last modified: Friday November 24th, 2023

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

Setting up a custom php.ini file

The php.ini file contains directives to control many PHP settings. You can set up one or more custom php.ini files to define how your website works. For example, you might have a custom file in the /home/username/public_html directory for your website’s main pages, and a separate custom file in the /home/username/public_html/images directory for your website’s image files.

 

Please follow these steps to set up a custom php.ini file:

  1. Log in to cPanel.
  2. Using the File Manager, navigate to the directory where you want to change the behavior of php. By default, a user’s php.ini file only affects the directory it is in.
  3. To create a new file сlick the File button in the File Manager toolbar, and name this file it php.ini.
  4. To edit the new php.ini click on the new file and then in the File Manager toolbar click the Edit button.
  5. Add php directives to the new php.ini, after then click the Save Changes button.
  6. After creating the php.ini file and setting its permissions, you can verify that the configuration is active. You can do this by creating a  phpinfo file in the directory where you created the php.ini
  7. Load the phpinfo file into your web browser and look for one of the directives you installed. Make sure the changes are displayed.
  8. You can create custom php.ini files for each directory in your website, but also you can 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 website’s document root directory. Replace username with your Beehosting 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.

Was this article helpful?
Views: 768

10 Years Beehosting!
Celebrate with 70% OFF + FREE Site Transfer.

Facebook Instagram linkedin

Beehosting.pro website uses cookies

We use cookies to personalise content and ads, to provide social media features and to analyse our traffic. We also share information about your use of our site with our social media, advertising and analytics partners who may combine it with other information that you’ve provided to them or that they’ve collected from your use of their services.

Menu