Enabling PHP-FPM (PHP FastCGI Process Manager) in cPanel/WHM automatically turns off a few features most notable the exec() function.

This function is most notably needed with WordPress plugins that process images or other files on your server. A good example is the popular EWWW Image Optimizer plugin.

Please note that the tutorial below is meant for cPanel/WHM users that plan on using PHP-FPM and wnat to enable exec() for a single domain. If you make these changes and then switch off PHP-FPM and switch it back on again, the configuration file will be automatically run over by WHM’s script.

What happens when you enable exec() in PHP you ask and why is it disabled by default? Well, it’s quite simple, this function allows your PHP script to make shell commands. Speaking security-wise, if you don’t know why you would need this function you probably don’t need it at all.

First, let’s check if we are using PHP-FPM for a specific domain.

1) Login to WHM.

2) Navigate to MultiPHP Manager to check whether the domain is using PHP-FPM or not.

3) From that page, you can verify that the domain is using PHP-FPM.

Now you can either login to your server as root via SSH (putty or similar software) or you can just use the Terminal tab in WHM.

4) Check the PHP version of the server using the below command.

php -v

5) Then open the PHP-FPM configuration file.

vi /opt/cpanel/ea-php72/root/etc/php-fpm.d/domain.tld.conf
Replace domain.tld with the actual domain.

6) Then you will find the exec() function in the disabled function list.

php_admin_value[disable_functions] = passthru,shell_exec,system

7) Remove that from the above line.

8) Then restart PHP-FPM using the below command.

/scripts/restartsrv_apache_php_fpm

You can also restart the service from WHM.

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.