CMS developers know that in the lamp environment for the background landing and uploading files, is very easy to occur in two places, and most of the problem is due to PHP configuration, so do a good job of PHP optimization is essential. For PHP optimization, mainly in the php.ini related to the main parameters of the reasonable adjustment and settings, the following we will look at some php.ini in the performance of a large number of parameters should be set (the system is CentOS).
(1) PHP function disabled find
Disable_functions =
This option can set which PHP functions are prohibited, PHP has some functions of the risk is quite large, you can directly execute some CentOS system-level script commands, if you allow these functions to execute, when the PHP program has a loophole, the loss is very serious! Here we give the recommended disabling 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 that CentOS System State detection, do not disable functions such as Shell_exec,proc_open,proc_get_status.
(2) PHP script execution time to find
Max_execution_time = 30
This option sets the maximum execution time for the PHP program, and if a PHP script is requested and the PHP script is not completed within the max_execution_time time, PHP does not continue to execute, returning the timeout error directly to the client. No special needs This option keeps the default setting for 30 seconds, and you can increase the time setting appropriately if your PHP script does require a long execution time.
(3) PHP script processing memory footprint found
Memory_limit = 8M
This option specifies the maximum memory that can be consumed by the PHP script processing, the default is 8MB, and if your 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 the web about PHP settings recommend that this option be set to ON, which is a dangerous way to set up, and is likely to cause serious security problems. If there is no special need, it is strongly recommended to keep the default settings!
(5) PHP upload file size limit to find
Upload_max_filesize = 2M
This option sets the maximum upload file size that PHP can allow, and the default is 2MB. Depending on the actual application requirements, you can increase this setting appropriately.
(6) Session storage media found
Session.save_path
If your PHP program uses the session dialog, you can set the sessions storage location to/DEV/SHM,/DEV/SHM is the Linux system unique TMPFS file system, is the memory as the main storage mode of the file system, more excellent than the RAMDisk, Because the Diskswap can be used as a supplement, but also is the CentOS system self-contained function module, do not need to be configured separately. Think about how fast you can get from disk IO to memory. Just be aware that the data stored in the/DEV/SHM will be lost when the server restarts. But this is insignificant for the session. This completes the process of PHP optimization in the CentOS system.