php.ini configuration and CMS program efficiency optimization configuration talk

Source: Internet
Author: User
Keywords Network programming PHP tutorial
Tags centos cms configuration configuration issues default developers environment file
Developers who have done CMS know that in the LAMP environment for background login and upload files are prone to problems in two places, and mostly because of PHP configuration issues, so make PHP optimization is essential. For the optimization of PHP, the main parameters of php.ini main reason for the appropriate adjustments and settings, let's take a look at some of the php.ini

Developers who have done CMS know that in the LAMP environment for background login and upload files are prone to problems in two places, and mostly because of PHP configuration issues, so make PHP optimization is essential. For PHP optimization, the main parameters of the php.ini reasonable adjustments and settings, the following we have a look at some of php.ini performance-influential parameters should be how to set up (the system is CentOS).

(1) PHP function disabled found

disable_functions =

This option can be set to which PHP functions are forbidden to use. Some PHP functions are still quite risky. Some CentOS system-level script commands can be executed directly. If these functions are allowed to execute, the loss is Very serious! Below we give the recommended disable function settings:

disable_functions = phpinfo, passthru, exec, system, popen, chroot, escapeshellcmd, escapeshellarg, shell_exec, proc_open, proc_get_status

Be careful: If your server contains some CentOS system status detection PHP program, do not disable the 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 PHP script fails to execute within the max_execution_time time, PHP will not continue executing and directly returns a timeout error to the client. There is no special need to keep the default setting for 30 seconds. If your PHP script really needs long execution time, you can increase the time setting appropriately.

(3) PHP script memory footprint found

memory_limit = 8M

This option specifies the maximum amount of memory that PHP scripting can take, defaults to 8MB, or 12MB if your server has more than 1GB of memory for faster processing of PHP scripting.

(4) PHP global function declaration found

register_globals = Off

Many articles on the PHP settings on the Internet recommend setting this option On, which is a dangerous setting 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 found

upload_max_filesize = 2M

This option allows PHP to allow the maximum upload file size, the default is 2MB. According to the actual application needs, you can increase the appropriate set.

(6) Session storage media found

session.save_path

If your PHP program to use the Session dialog, you can set the session storage location to / dev / shm, / dev / shm Linux system is a unique TMPFS file system is based on memory as the main storage file system more than RAMDISK Excellent, because you can use DISKSWAP as a supplement, but also comes with CentOS system function modules, do not need to be configured separately. Think about it, from disk IO operation to memory operation, how fast? Just need to be aware that the data stored in / dev / shm will be lost after the server reboot. But this is insignificant for the Session. So we have completed the PHP optimization steps in CentOS system.

Related Article

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.