How To Enable or Disable Shell_exec in PHP

How To Enable or Disable Shell_exec in PHP

First you need to find the location of PHP.ini. You will need to have root access to your server before you can perform the following steps

Type this command in the shell:

php --ini

It should output this text:

Configuration File (php.ini) Path: /usr/local/lib
Loaded Configuration File: /usr/local/lib/php.ini

Enable Exec() in PHP.ini

Open the PHP.ini file and remove ?exec? on ?disable_functions?:

disable_functions=show_source, system, shell_exec, exec

So it will become like this:

disable_functions=show_source, system, shell_exec

Then restart PHP service, use one of these commands:

/etc/init.d/php-fpm restart
/etc/init.d/php5-fpm restart
/etc/init.d/php7.0-fpm restart

Disable Exec() in PHP.ini

Open the PHP.ini file and add ?exec? on ?disable_functions?:

disable_functions=show_source, system, shell_exec

So it will become like this:

disable_functions=show_source, system, shell_exec, exec

Then restart PHP service, use one of these commands:

/etc/init.d/php-fpm restart
/etc/init.d/php5-fpm restart
/etc/init.d/php7.0-fpm restart

Share this post