PHP.INI settings Disable exec, shell_exec, system, popen and Other Functions To Improve Security

www.‮ruttual‬i.com
PHP.INI settings Disable exec, shell_exec, system, popen and Other Functions To Improve Security

To disable certain functions in PHP, such as exec, shell_exec, system, and popen, you can modify the disable_functions directive in the php.ini configuration file. Here are the steps you can follow to disable these functions in PHP:

  1. Find the location of the php.ini file:

  2. The php.ini file is the main configuration file for PHP. To find its location, you can use the phpinfo function to display the path to the file:

<?php
phpinfo();
?>
  1. Save the file as phpinfo.php and place it in your web server's document root. Then, access the file in a web browser to view the PHP information page.

  2. Look for the "Loaded Configuration File" setting in the PHP information page. The path to the php.ini file will be listed under this setting.

  3. Modify the disable_functions directive:

  4. Open the php.ini file in a text editor and locate the disable_functions directive.

  5. Add the functions that you want to disable to the directive. For example, to disable the exec, shell_exec, system, and popen functions, you can set the directive as follows:

disable_functions = exec, shell_exec, system, popen
  1. Save the changes to the php.ini file.

  2. Restart the web server:

  3. After modifying the php.ini file, you will need to restart the web server for the changes to take effect.

Note that disabling certain functions in PHP can improve security by preventing malicious code from being executed on your server. However, it is important to carefully consider the implications of disabling these functions, as they may be needed by certain scripts and applications. Consult the PHP documentation for more information on the disable_functions directive and the functions it can disable.

Created Time:2017-10-30 14:27:09  Author:lautturi