php 参数优化

来源:互联网 发布:淘宝店铺大图怎么做 编辑:程序博客网 时间:2024/06/16 16:00
一、修改php参数
 
1、修改php启动的配置文件
vi /usr/local/webserver/php/etc/php-fpm.conf
 
php5.2.x
 
max_children
修改为200对应4G
修改为300对应8G
 
php5.3.x
 
ps:如果pm=static
 
     pm.max_children:静态方式下开启的php-fpm进程数量。
 
ps:如果pm=dynamic
 
     pm.start_servers:动态方式下的起始php-fpm进程数量
     pm.min_spare_servers:动态方式下的最小php-fpm进程数量
     pm.max_spare_servers:动态方式下的最大php-fpm进程数量
 
 
2、rlimit_files
修改为65535
 
 
二、修改系统参数
 
1、系统参数
 
vi /etc/sysctl.conf
 
net.ipv4.tcp_max_syn_backlog = 65536
net.core.netdev_max_backlog =  32768
net.core.somaxconn = 32768
 
net.core.wmem_default = 8388608
net.core.rmem_default = 8388608
net.core.rmem_max = 16777216
net.core.wmem_max = 16777216
 
net.ipv4.tcp_timestamps = 0
net.ipv4.tcp_synack_retries = 2
net.ipv4.tcp_syn_retries = 2
 
net.ipv4.tcp_tw_recycle = 1
#net.ipv4.tcp_tw_len = 1
net.ipv4.tcp_tw_reuse = 1
 
net.ipv4.tcp_mem = 94500000 915000000 927000000
net.ipv4.tcp_max_orphans = 3276800
#
net.ipv4.tcp_fin_timeout = 30
net.ipv4.tcp_keepalive_time = 120
net.ipv4.ip_local_port_range = 1024  65535
#
vm.overcommit_memory = 1
 
 
2、调高linux内核打开文件数量
 
1)环境变量调整
echo 'ulimit -HSn 65535' >> /etc/profile
echo 'ulimit -HSn 65535' >> /etc/rc.local
 
source /etc/profile
 
2)、limits.conf调整
vi  /etc/security/limits.conf
 
*        soft    nofile  65535
*        hard    nofile  65535
0 0
原创粉丝点击