On cPanel servers, PHP-FPM is commonly used to improve PHP performance. However, in some cases, PHP functions such as exec() may not work when PHP-FPM is enabled. This usually happens because the function is listed under disabled functions in the PHP configuration, not because PHP-FPM itself blocks it.
This guide explains how to enable the exec() function in PHP-FPM on a cPanel/WHM server.
Note: Enabling exec() can pose security risks. It should only be enabled if your application explicitly requires it and the server is properly secured.
Steps to allow exec() in PHP-FPM:
- To begin, make sure PHP-FPM is enabled on the domain that is experiencing the issue. Follow the steps below:
- Log in to WHM.
- You can check if your domain uses PHP-FPM by navigating to MultiPHP Manager.
- You can verify whether PHP-FPM is being used by the domain on that page.
- Your server now has PHP-FPM installed. To enable exec() in PHP-FPM, follow the steps below:
- Connect via SSH to the server.
- Use the following command to check the PHP version of the server.
#php -v
- Open the PHP-FPM configuration file.
# vi /opt/cpanel/ea-php70/root/etc/php-fpm.d/blah.domain.tld.conf
- You will find the exec() function in the disabled function list.
php_admin_value[disable_functions] = passthru,shell_exec,system
- Remove “exec” from the upper line.
- Use the following command to restart PHP-FPM.
# /scripts/restartsrv_apache_php_fpm
On cPanel/WHM servers, exec() may not work under PHP-FPM if it is disabled in the PHP-FPM configuration. Updating the domain-specific PHP-FPM configuration file and restarting the service successfully enables the function.
If you need further assistance, don’t hesitate to get in touch with our support team.