PHP is a scripting language commonly used to build websites and web applications.
PHP natvie core 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 and other stuffs.
While there are literally thousands of possible combinations, developers can usually find a happy balance that allows all of websites 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:
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.
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 /usr/local/lib/php.ini
The DSO handler does not allow for more than one php.ini per Apache instance. Instead, you may make minor adjustments in a .htaccess file located in the public_html folder for the domain needing customization.
suPHP is the cPanel default and most commonly used PHP handler. It also comes pre-configured to allow a custom php.ini file placed wherever you need to change PHP configuration values. This “convenience”, however, is limited to affecting only the folder where the php.ini file resides. So to affect multiple folders or sub-folders you would need multiple copies of this file; one file per folder. This is easily resolved however by following the following easy steps:
/home/cpanlusr/public_html/
<IfModule mod_suphp.c> suPHP_ConfigPath /home/<cPanel user>/public_html/php.ini </IfModule> <Files php.ini> order allow,deny deny from all </Files>
/home/cpanlusr/public_html/
). Connecting as the root user and running the following command in your favorite terminal application should do the trick. Be sure to update the second folder path to match where you want the new php.ini file created:cp /usr/local/lib/php.ini /home/cpanlusr/public_html/cgi-bin/
/usr/local/cpanel/cgi-sys/php5
. Before editing any server file, however, it is a good idea to create a backup first. Run the following command in your terminal application to do so:cp -frp /usr/local/cpanel/cgi-sys/php5 /usr/local/cpanel/cgi-sys/php5.bk
nano /usr/local/cpanel/cgi-sys/php5
#!/bin/sh # If you customize the contents of this wrapper script, place # a copy at /var/cpanel/conf/apache/wrappers/php5 # so that it will be reinstalled when Apache is updated or the # PHP handler configuration is changed exec /usr/bin/php
We’re going to add a new line just before the last one at the bottom [[ -f ~/public_html/php.ini ]] && exec /usr/bin/php -c ~/public_html/php.ini
so that the file now looks like:
#!/bin/sh # If you customize the contents of this wrapper script, place # a copy at /var/cpanel/conf/apache/wrappers/php5 # so that it will be reinstalled when Apache is updated or the # PHP handler configuration is changed [[ -f ~/public_html/php.ini ]] && exec /usr/bin/php -c ~/public_html/php.ini exec /usr/bin/php
NOTE: If you’re just following along and not familiar with the nano editor, you will press Ctrl+X to close the file and press Y when asked if you want to save your changes.
mkdir -p /var/cpanel/conf/apache/wrappers
cp -frp /usr/local/cpanel/cgi-sys/php5 /var/cpanel/conf/apache/wrappers/php5
service httpd restart
Each failover IP address will need its own line in the configuration file. The configuration…
What is mdadm? The mdadm utility can be used to create and manage storage arrays…
There are several scenarios that you might need to increase or decrease your php maximum…
What is Let’s Encrypt? Let’s Encrypt is a free certificate authority provided by the Internet…
Python normally installed on all cPanel hosting server because most of Centos/red hat update system…
Usually CentOS 7 comes in a numbers of variants, For most users, there are two…