How to disable dangerous functions in PHP

Dangerous functions in PHP

Running the following PHP functions can compromise the execution of your scripts or servers.

Run the following command for the versions of PHP you need to disable.

PHP switcher:

echo "disable_functions = exec, system, popen, proc_open, shell_exec, passthru, show_source" > /usr/local/php/php.d/disabled_function.ini

PHP-CGI selector:

echo "disable_functions = exec, system, popen, proc_open, shell_exec, passthru, show_source" > /opt/alt/php53/usr/php/php.d/disabled_function.ini

echo "disable_functions = exec, system, popen, proc_open, shell_exec, passthru, show_source" > /opt/alt/php54/usr/php/php.d/disabled_function.ini

echo "disable_functions = exec, system, popen, proc_open, shell_exec, passthru, show_source" > /opt/alt/php55/usr/php/php.d/disabled_function.ini

echo "disable_functions = exec, system, popen, proc_open, shell_exec, passthru, show_source" > /opt/alt/php56/usr/php/php.d/disabled_function.ini

echo "disable_functions = exec, system, popen, proc_open, shell_exec, passthru, show_source" > /opt/alt/php70/usr/php/php.d/disabled_function.ini

echo "disable_functions = exec, system, popen, proc_open, shell_exec, passthru, show_source" > /opt/alt/php71/usr/php/php.d/disabled_function.ini

echo "disable_functions = exec, system, popen, proc_open, shell_exec, passthru, show_source" > /opt/alt/php72/usr/php/php.d/disabled_function.ini

echo "disable_functions = exec, system, popen, proc_open, shell_exec, passthru, show_source" > /opt/alt/php73/usr/php/php.d/disabled_function.ini

PHP_FPM Selector:

You need to restart php-fpm for the changes to take effect.

echo "disable_functions = exec, system, popen, proc_open, shell_exec, passthru, show_source" > /opt/alt/php-fpm53/usr/php/php.d/disabled_function.ini && service php-fpm53 restart

echo "disable_functions = exec, system, popen, proc_open, shell_exec, passthru, show_source" > /opt/alt/php-fpm54/usr/php/php.d/disabled_function.ini && service php-fpm54 restart

echo "disable_functions = exec, system, popen, proc_open, shell_exec, passthru, show_source" > /opt/alt/php-fpm55/usr/php/php.d/disabled_function.ini && service php-fpm55 restart

echo "disable_functions = exec, system, popen, proc_open, shell_exec, passthru, show_source" > /opt/alt/php-fpm56/usr/php/php.d/disabled_function.ini && service php-fpm56 restart

echo "disable_functions = exec, system, popen, proc_open, shell_exec, passthru, show_source" > /opt/alt/php-fpm70/usr/php/php.d/disabled_function.ini && service php-fpm70 restart

echo "disable_functions = exec, system, popen, proc_open, shell_exec, passthru, show_source" > /opt/alt/php-fpm71/usr/php/php.d/disabled_function.ini && service php-fpm71 restart

echo "disable_functions = exec, system, popen, proc_open, shell_exec, passthru, show_source" > /opt/alt/php-fpm72/usr/php/php.d/disabled_function.ini && service php-fpm72 restart

echo "disable_functions = exec, system, popen, proc_open, shell_exec, passthru, show_source" > /opt/alt/php-fpm73/usr/php/php.d/disabled_function.ini && service php-fpm73 restart

Para volver a habilitarlo, simplemente elimine el archivo disabled_function.ini para la versión de PHP que desee y reinicie apache/php-fpm.

Note: Disabling the following PHP functions is a recommendation from the CWP 7 Web panel author.
If you have any questions, feel free to contact the Picaraza Domains Ltd support team 24/7/365.
Was this answer helpful?

Related Articles

How to open ports in Web Panel CWP 7

Port configuration in CWP 7The CWP 7 panel we can configure the CSF / LFD firewall using the CSF...