1. Find the PHP script execution time
max_execution_time = 30
This option sets the maximum execution time of the PHP program. If a PHP script is requested and the PHP script fails to be executed within the max_execution_time time,
Then PHP will no longer continue execution and directly return a timeout error to the client. There is no special need for this option. Keep the default setting of 30 seconds. If your PHP script really needs a long execution time, you can increase the time appropriately.
set up.
2. 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 your server If the memory is more than 1GB, this option can be set to 12MB for faster PHP script processing efficiency.
3. Disable PHP functions. Find disable_functions =
This option can set which PHP functions are prohibited from use. Some functions in PHP are quite risky. You can directly Execute some CentOS system-level script commands. If these functions are allowed to execute, when a vulnerability occurs in the PHP program, the losses 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 your server contains some PHP programs for CentOS system status detection, do not disable shell_exec, proc_open, proc_get_status and other functions.
4. Find the PHP global function declaration
register_globals = Off
Many articles about PHP settings on the Internet recommend setting this option to On. In fact, this is a And its dangerous setting method may cause serious safety problems. If there are no special needs, it is highly recommended to keep the default settings!
5. Find the Session storage medium
session.save_path
If your PHP program uses Session dialogue, you can Set the Session storage location to /dev/shm. /dev/shm is the TMPFS file system unique to the Linux system. It is a file system that uses memory as the main storage method. It is better than RAMDISK because DISKSWAP can be used as a supplement, and it is The CentOS system comes with function modules and does not need to be configured separately. Think about it, how much faster will it be from disk IO operations to memory operations? Just note that all data stored in /dev/shm will be lost after the server is restarted. But this is insignificant for Session. In this way, we have completed the steps of PHP optimization on CentOS system.
6. 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 appropriately increased according to actual application requirements.
I hope the above mentioned can be helpful to PHP enthusiasts.