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