##PHP配置##
php-fpm设置:
一./etc/php/5.5/fpm/pool.d/www.conf中
pm.max_children = 200
pm.start_servers = 9
pm.min_spare_servers = 9
pm.max_spare_servers = 150
listen.backlog = 4096

PHP.ini配置:
二./etc/php/5.5/fpm/php.ini
memory_limit= 10240M
php opcache设置:
三./etc/php/5.5/fpm/conf.d/10-opcache.ini:
opcache.enable=1
opcache.enable_cli  1
opcache.fast_shutdown  1
opcache.file_update_protection   0
opcache.max_accelerated_files  100000
opcache.memory_consumption  5120
opcache.revalidate_freq  10
##nginx配置##
/etc/nginx/nginx.conf
worker_processes auto;
worker_rlimit_nofile 200000;
events {
worker_connections 10240;
#multi_accept on;
}
access_log off;
##linux 内核参数##
编辑文件vi /etc/sysctl.conf,加入以下内容:解决大量TIME_WAIT
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_fin_timeout = 30
解决高并发的时候PHP-fpm出现一些错误  connect() to unix:/var/run/php-fpm.sock failed (11: Resource temporarily unavailable) :
net.ipv4.tcp_max_syn_backlog = 4096
net.core.netdev_max_backlog = 4096
然后执行 sysctl -p 让参数生效。
/etc/security/limits.conf:
* soft nofile 1048576
* hard nofile 1048576
root soft nofile 1048576
root hard nofile 1048576
然后重启服务器
临时修改的话ulimit -n 1048576就可以了,不用重启服务器
查看是否生效
ulimit -a
https://www.emqx.io/docs/zh/v5.0/deploy/tune.html#linux-%E6%93%8D%E4%BD%9C%E7%B3%BB%E7%BB%9F%E5%8F%82%E6%95%B0
https://wiki.swoole.com/#/other/sysctl

PHP与nginx及linux的性能设置.
标签: