Centos7 PHP Performance Tuning

Source: Internet
Author: User
Tags php performance tuning safe mode

Php-ini Optimization

Vi/etc/php.ini

Open PHP Safe Mode, control PHP execute dangerous function, default is off, change to On

Sql.safe_mode = Off

Close PHP header information, hide version number, default is on, this is off

expose_php = On

Error message Output control

Display_error = Off

error_reporting = e_warning & E_error

Log error logs to the background for easy traceability

Log_errors = On

Error_log =/var/log/php_error.log

Maximum memory per script time

Memory_limit = 128M

Upload file maximum license, default 2M, recommended adjustment to 16,32m

Upload_max_filesize = 2M

Disable remote execution of Phpshell, default on, recommended off

Allow_url_fopen = On

Time zone adjustment, default PRC, recommended adjustment to Asia/shanghai

Date.timezone = PRC

Overall optimized post-configuration file

Sql.safe_mode = Off

expose_php = Off

Display_error = Off

error_reporting = e_warning & E_error

Log_errors = On

Error_log =/var/log/php_error.log

Upload_max_filesize = 50M

Allow_url_fopen = Off

Date.timezone = Asia/shanghai

PHP-FPM Optimization

PHP-FPM configuration file 4-core 16G, 8-Core 16G

[Email protected] ~]# cat/etc/php-fpm.d/www.conf

[Global]

PID =/var/run/php-fpm.pid

#php-FPM Program error log

Error_log =/var/log/php/php-fpm.log

Log_level = Warning

Rlimit_files = 655350

Events.mechanism = Epoll

User Privilege Optimization

[WWW]

user = Nginx

Group = Nginx

Listen = 127.0.0.1:9000

Listen.owner = www

Listen.group = www

Listen.mode = 0660

Listen.allowed_clients = 127.0.0.1

Process number Optimization

PM = dynamic

Pm.max_children = #一般来说一台服务器正常情况下每一个php-cgi consumes about 20M of memory, so my "Max_children" I set to 40, 20m*40= 800M means that at peak time all php-cgi are within 800M, below my valid memory 1Gb.

Pm.start_servers = 10

Pm.min_spare_servers = 10

Pm.max_spare_servers = 30

Pm.process_idle_timeout = 15s;

Maximum number of requests optimized

Pm.max_requests = 2048

#php-www Module Error log

Php_flag[display_errors] = Off

Php_admin_value[error_log] =/var/log/php/php-www.log

Php_admin_flag[log_errors] = On

#php慢查询日志

Request_slowlog_timeout = 5s

Slowlog =/var/log/php/php-slow.log

Learn more here to see this blog: https://www.cnblogs.com/kenshinobiy/p/7470635.html

Centos7 PHP Performance Tuning

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.