How to change PHP handler from command line – cPanel server

Why PHP handlers?

Simply to serve PHP scripts on the web servers to web browser or end user. It’s a type of Apache module for executing PHP code. A PHP handlers deliver the PHP programming libraries into web server. Different types of php handlers are available such as CGI, DSO, suPHP, & FastCGI. Each handler delivers the libraries through different files and implementations. Each file and implementation affects Apache’s performance, because it determines how Apache serves PHP.

In a cPanel server, we have command-line options to list and change PHP handlers.

To list current handler

# /usr/local/cpanel/bin/rebuild_phpconf --current


# /usr/local/cpanel/bin/rebuild_phpconf --current
Available handlers: suphp dso cgi none
PHP4 SAPI: none
PHP5 SAPI: suphp
SUEXEC: enabled
RUID2: not installed


Above command lists the current PHP handler and all other available handlers in the server.

To list all available PHP handlers on server

# /usr/local/cpanel/bin/rebuild_phpconf --available

To change the current PHP handler to “DSO”

Before executing this command please make sure that the web server Apache is compiled with DSO.

# /usr/local/cpanel/bin/rebuild_phpconf 4 dso none 1

To change the current PHP handler to “SuPHP”

# /usr/local/cpanel/bin/rebuild_phpconf 5 none suphp 1


root@test [~]# /usr/local/cpanel/bin/rebuild_phpconf 5 none suphp 1
[/usr/local/cpanel/scripts/set_mailman_archive_perms] Setting I/O priority to reduce system load: best-effort: prio 6
[/usr/local/cpanel/scripts/set_mailman_archive_perms] Setting mailman archive permissions
[/usr/local/cpanel/scripts/set_mailman_archive_perms] Continuing in the background
php.conf updated to:

# This file was automatically generated by the Cpanel PHP Configuration system
# If you wish to change the way PHP is being handled by Apache on your system,
# use the /usr/local/cpanel/bin/rebuild_phpconf script or the WHM interface.
# Manual edits of this file will be lost when Apache is updated.

# SuPHP configuration for PHP5
LoadModule suphp_module modules/
suPHP_Engine on
AddType application/x-httpd-php5 .php5 .php4 .php .php3 .php2 .phtml

    suPHP_AddHandler application/x-httpd-php5

# End of autogenerated PHP configuration.

Updating user configurable PHP settings.
[info] recursion depth is set to: 2
Restarting Apache

It will change the default PHP handler to SuPHP

To change the current PHP handler to CGI

# /usr/local/cpanel/bin/rebuild_phpconf 5 none cgi 1

To change the current php handler to FastCGI

# /usr/local/cpanel/bin/rebuild_phpconf 5 none fcgi 1

That’s it!!
Thank you.

How to change PHP handler from SuPHP to FastCGI in a cPanel server
Command-line option to list the current PHP handler on the server – cPanel

Post navigation

Arunlal A

Senior System Developer at Zeta. Linux lover. Traveller. Let's connect! Whether you're a seasoned DevOps pro or just starting your journey, I'm always eager to engage with like-minded individuals. Follow my blog for regular updates, connect on social media, and let's embark on this DevOps adventure together! Happy coding and deploying!

One thought on “How to change PHP handler from command line – cPanel server

Leave a Reply

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