How to set optimization parameters in php: 1. Set the disable_functions option; 2. Set the maximum execution time of the php program; 3. Set the php script to handle memory usage; 4. Set the php global function declaration; 5. Set the php Upload file size limit.
Optimization parameter settings:
(recommended related video tutorials: java video tutorial)
(1) PHP function disable found:
disable_functions =
This option can set which PHP functions are prohibited from use. Some functions in PHP are quite risky and can be executed directly. Some system-level script commands, if these functions are allowed to execute, when a vulnerability occurs in the PHP program, the loss will be very serious! Below we give the recommended disabled function settings:
disable_functions = phpinfo,passthru,exec,system,popen,chroot,escapeshellcmd,escapeshellarg,shell_exec,proc_open,proc_get_status
Note: If you If your server contains some PHP programs for system status detection, do not disable shell_exec, proc_open, proc_get_status and other functions.
(2) PHP script execution time found:
max_execution_time = 30
This option sets the maximum execution time of the PHP program. If a PHP script is requested and the If the PHP script fails to be executed within the max_execution_time, PHP will no longer continue execution and will directly return a timeout error to the client. If there is no special need for this option, keep the default setting of 30 seconds. If your PHP script really requires a long execution time, you can increase the time setting appropriately.
(3) PHP script processing memory usage found:
memory_limit = 8M
This option specifies the maximum memory that PHP script processing can occupy. The default is 8MB. If you If the server memory is more than 1GB, this option can be set to 12MB for faster PHP script processing efficiency.
(4) PHP global function declaration found:
register_globals = Off
Many articles on PHP settings on the Internet recommend setting this option to On. In fact, this is An extremely dangerous setting method that may cause serious security issues. If there are no special needs, it is highly recommended to keep the default settings!
(5) PHP upload file size limit found:
upload_max_filesize = 2M
This option sets the maximum upload file size allowed by PHP, the default is 2MB. This setting can be increased appropriately based on actual application requirements.
Related recommendations: php training
The above is the detailed content of How to set optimization parameters in php. For more information, please follow other related articles on the PHP Chinese website!