How to set up a custom php.ini file?

A php.ini file contains directives that allow you to modify several PHP settings. You can define how your website works by creating one or more custom php.ini files. For example, you might have a custom file in your /home/username/public_html directory for your main pages and a different custom file in your /home/username/public_html/images directory for your image files.

Follow these steps to create a custom php.ini file:

1.Log in to your cPanel account.

2.Navigate to the directory where you wish to change the behavior of php using the File Manager. A custom php.ini file affects only the directory in which it is located by default. 

3.To create a new file, click the File button in the File Manager toolbar and name it php.ini.

4.To modify the new php.ini, click the new file and then the modify button in the File Manager toolbar.

5.Add php directives to the new php.ini file, then save the changes.

6.You may check that the configuration is active once you create the php.ini file and set its permissions. Create a phpinfo file in the same location as you created the php.ini.

7.Open the phpinfo file in your web browser and look for one of the directives you configured. Check that the changes are visible.

8.Although you can create specific php.ini files for each directory on your website, many people modify settings in a single php.ini file and then apply it to the entire site. To accomplish this, add the following line to the.htaccess file in the document root directory of your website. Username should be replaced with your Hostginger Hosting username:

lsapi_phpini /home/username/public_html/php.ini

 

Was this answer helpful?

Related Articles

What is PHP?

PHP (recursive acronym for PHP: Hypertext Preprocessor) is a popular open source general-purpose...

What permissions do I need to set for my PHP script files?

To avoid difficulties, set the PHP script file permissions to 755 (read, write, and execute...

Where can I find the PHP executable?

The absolute path to the PHP executable on Hostginger Hosting's servers is /usr/local/bin/php.