Symptoms
An error message like this appears in your PHP application's error log:
[2020-04-22 16:30:01] local.ERROR: ErrorException: exec() has been disabled for security reasons
Description
This error indicates that the exec() function is disabled in the global php.ini
file for the version of PHP the application is using--for example, for ea-php72:
[root@server ~]cPs# grep disable_functions /opt/cpanel/ea-php72/root/etc/php.ini
disable_functions = show_source, system, shell_exec, passthru, exec, popen, proc_open
The error can also indicate that exec() is disabled in either the domain's individual PHP-FPM configuration or in the global PHP-FPM configuration.
Workaround
If the domain is using regular PHP, use the cPanel MultiPHP INI Editor at Home >> Software >> MultiPHP INI Editor to create a local php.ini
file for the affected user in which the exec() function is removed from the list of disabled functions, for example:
[user@server ~]$ more php.ini
; cPanel-generated php ini directives, do not edit
; Manual editing of this file may result in unexpected behavior.
; To make changes to this file, use the cPanel MultiPHP INI Editor (Home >> Software >> MultiPHP INI Editor)
; For more information, read our documentation (https://go.cpanel.net/EA4ModifyINI)
disable_functions = show_source, system, shell_exec, passthru, popen, proc_open
If the domain is using PHP-FPM, refer to this article to learn how to disable the function: How to modify disable_functions in WHM when using PHP-FPM.