PHP customization in cPanel
As you probably already know, PHP is a scripting language commonly used to build websites and web applications. What you may not know is that PHP can be customized to better meet the needs of your website or chosen Content Management System (CMS). This customization can fulfill many purposes, from increasing the memory available to changing security settings.
While there are literally thousands of possible combinations, your developer can usually find a happy balance that allows all of your sites to function without affecting each other. When this is the case, it is always recommended to simply make the necessary changes through WHM by choosing the PHP Configuration Editor option under the Service Configuration heading:
If for some reason this is not possible, for instance if two of your sites require conflicting configuration values, it becomes necessary to customize PHP configuration settings for each domain (or at least for the conflicting domain).
cPanel currently offers four different PHP handlers; four different interpreters for PHP to use to communicate with the web server (generally Apache). Each of these handlers has it’s own story and it’s own pros and cons, details that are better left for an article of their own. The important thing to note is that while all four of these handlers allow for customizing PHP for individual domains, the steps to accomplish this end differ considerably. To make this often necessary task a little easier, we have assembled the following instructions customized for each PHP handler.
Instructions for customizing PHP for each handler
One important note before we begin:
CGI and FastCGI require the custom php.ini to contain a full PHP configuration, while DSO and suPHP can contain only those parameters you wish to override. For consistency and to facilitate easier switching between modes, however, we will recommend that regardless of the PHP handler you choose to use a full PHP configuration file. The default location for the main php.ini file on your cPanel server to copy should be
- Create a copy of the full PHP configuration file (php.ini) inside of the domain’s public_html folder (ie:
- In the same folder, create or edit the .htaccess file and place the following code at the top, being sure to update the second line of code to match your current folder location:
<IfModule mod_suphp.c> suPHP_ConfigPath /home/<cPanel user>/public_html/php.ini </IfModule> <Files php.ini> order allow,deny deny from all </Files>
- Your custom php.ini file should now function for both the public_html/ folder it resides in and any folder within as well.