How to Allow exec() in PHP-FPM

November 30, 2022 / Web Development

In this article, we will explain how to allow exec in PHP-FPM. Occasionally, the exec() function does not work after turning on PHP-FPM, and we cannot find any disabled functions in the PHP configuration file. We can exec again after turning off PHP-FPM.

Please follow these steps if you are experiencing this issue:

  1. To begin, make sure PHP-FPM is enabled on the domain that is experiencing the issue. Follow the steps below-
    1. Login to WHM.
    2. You can check if your domain uses PHP-FPM by navigating to MultiPHP Manager.
    3. You can verify whether PHP-FPM is being used by the domain on that page.
  2. Your server now has PHP-FPM installed. To enable exec() in PHP-FPM, follow the steps below-
    1. Connect via SSH to the server.
    2. Use the following command to check the PHP version of the server.
      #php -v
    3. Open the PHP-FPM configuration file.
      # vi /opt/cpanel/ea-php70/root/etc/php-fpm.d/blah.domain.tld.conf
    4. You will find the exec() function in the disabled function list.
      php_admin_value[disable_functions] = passthru,shell_exec,system
    5. Remove “exec” from the upper line.
    6. Use the following command to restart PHP-FPM.
      # /scripts/restartsrv_apache_php_fpm

This way exec() works. For any extra assistance with web hosting, feel free to contact our support team.

Dominos Search