Php. ini configuration and CMS program efficiency optimization configuration

Source: Internet
Author: User
Developers who have done CMS know that background login and file upload in the LAMP environment are very prone to problems. most of them are due to PHP configuration problems, so it is vital to optimize PHP. PHP optimization is mainly for php. the main parameters in ini are adjusted and set properly. let's take a look at php below. <LINKhref = "http: // www.

Developers who have done CMS know that background login and file upload in the LAMP environment are very prone to problems. most of them are due to PHP configuration problems, so it is vital to optimize PHP. PHP optimization is mainly for php. the main parameters in ini are adjusted and set properly. let's take a look at php below. how to set some parameters in ini that have a major impact on performance (the system is CentOS ).

(1) disable finding PHP functions

Disable_functions =

This option can be used to set which PHP functions are not allowed to be used. some functions in PHP are highly risky. you can directly execute some CentOS system-level script commands. if these functions are allowed to be executed, when a PHP program has a vulnerability, the loss is very serious! The recommended function settings are as follows:

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.

(2) 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 cannot be executed within max_execution_time, PHP will not continue to run, A timeout error is returned directly to the client. If this option is not required, the default setting is 30 seconds. if your PHP script needs to be executed for a long time, you can increase the setting accordingly.

(3) Find the memory occupied by PHP script processing

Memory_limit = 8 M

This option specifies the maximum memory occupied by PHP script processing. the default value is 8 MB. if your server memory is more than 1 GB, this option can be set to 12 MB for faster PHP script processing efficiency.

(4) PHP global function declaration found

Register_globals = Off

Many articles On PHP settings On the network recommend that you set this option to On. In fact, this is an extremely dangerous setting method, which may cause serious security problems. If you do not have special requirements, we strongly recommend that you keep the default settings!

(5) limit on the size of PHP files to be uploaded

Upload_max_filesize = 2 M

This option sets the maximum file size that PHP can upload. the default value is 2 MB. You can increase the setting as needed.

(6) find the Session storage medium

Session. save_path

If your PHP program uses Session dialogs, you can set the Session storage location to/dev/shm./dev/shm is a TMPFS file system exclusive to the Linux system, the file system is mainly stored in memory, which is better than RAMDISK, because DISKSWAP can be used as a supplement and is a function module provided by CentOS system without additional configuration. Think about the speed from disk I/O operations to memory operations? Note that all data stored in/dev/shm is lost after the server is restarted. However, this is insignificant for the Session. In this way, we have completed the PHP optimization steps in the CentOS system.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.