This article describes how to use custom php.ini files to control PHP settings for your web site.
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:
- Log in to cPanel
- 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.
- Click the File button in the File Manager toolbar to create a new file and name it php.ini.
- Click on the new file and then click the Edit button in the File Manager toolbar to edit the new php.ini.
- Add php directives to the new php.ini and then click the Save Changes button.
- 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
- Load the phpinfo file in your web browser, and locate one of the directives you set. Make sure the changes are shown.
- 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