Changing PHP handlers outside of WHM

cPanel makes it easy to change the handler Apache uses to interpret and execute PHP code. Changing the PHP handler is much quicker if done through the command line.

EasyApache 3
With EA3 the PHP handler can be changed with /usr/local/cpanel/bin/rebuild_phpconf using the following syntax:

DEFAULT_PHPVER PHP4_HANDLER PHP5_HANDLER SUEXEC_MODRUID2
For example
Current (suPHP + SUEXEC):

root@openstack.donthurt.us:~ # /usr/local/cpanel/bin/rebuild_phpconf --current
Available handlers: suphp dso cgi none
DEFAULT PHP: 5
PHP4 SAPI: none
PHP5 SAPI: suphp
SUEXEC: enabled
RUID2: not installed

  • New (mod_php/DSO + mod_ruid2):
root@openstack.donthurt.us:~ # /usr/local/cpanel/bin/rebuild_phpconf 5 none dso 1
root@openstack.donthurt.us:~ # /usr/local/cpanel/bin/rebuild_phpconf --current
Available handlers: suphp dso cgi none
DEFAULT PHP: 5
PHP4 SAPI: none
PHP5 SAPI: dso
SUEXEC: enabled
RUID2: enabled

EasyApache 4
With the advent of EA4 we can now have multiple version of PHP running concurrently each with different PHP handlers.

Changing the PHP handler in EA4 is done with the same command, although, the syntax differs slightly:

DEFAULT_VERSION VERSION_HANDLER

  • For example:

  • Current (PHP 5.6 default with cgi):

root@openstack.donthurt.us:~ # /usr/local/cpanel/bin/rebuild_phpconf --current
DEFAULT PHP: ea-php56
ea-php54 SAPI: cgi
ea-php55 SAPI: cgi
ea-php56 SAPI: cgi
  • New (PHP 5.5 default with mod_php/DSO):
root@openstack.donthurt.us:~ # /usr/local/cpanel/bin/rebuild_phpconf --default=ea-php55 --ea-php55=dso
root@openstack.donthurt.us:~ # /usr/local/cpanel/bin/rebuild_phpconf --current
DEFAULT PHP: ea-php55
ea-php54 SAPI: cgi
ea-php55 SAPI: dso
ea-php56 SAPI: cgi
  • Multiple handlers can be changed at once as well:
root@openstack.donthurt.us:~ # /usr/local/cpanel/bin/rebuild_phpconf --default=ea-php56 --ea-php56=suphp --ea-php55=dso --ea-php54=cgi
root@openstack.donthurt.us:~ # /usr/local/cpanel/bin/rebuild_phpconf --current
DEFAULT PHP: ea-php56
ea-php54 SAPI: cgi
ea-php55 SAPI: dso
ea-php56 SAPI: suphp

The mod_php and suPHP handlers do not come with the standard EasyApache 4 installation, they must be installed via yum (replace ea-phpXX-php with the PHP version you want to install mod_php for):

root@openstack.donthurt.us:~ # yum install ea-apache24-mod_suphp
root@openstack.donthurt.us:~ # yum install ea-phpXX-php

Leave a Reply

Your email address will not be published. Required fields are marked *