继续上文CentOS6.5
Nginx优化编译配置本文记录有关Nginx系统环境的一些细节设置,有关Nginx性能调整除了配置文件吻合服务器硬件之前就是关闭不必要的服务、磁盘操作、文件描述符、内核调整等。
1、关闭系统中不需要的服务
###Centos minimal 本来就是最小安装,这里我也就不提建议了,跟着自己的环境来###[[email protected]-it ~]# chkconfig --list
auditd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
blk-availability 0:off 1:on 2:on 3:on 4:on 5:on 6:off
crond 0:off 1:off 2:on 3:on 4:on 5:on 6:off
ip6tables 0:off 1:off 2:on 3:on 4:on 5:on 6:off
iptables 0:off 1:off 2:on 3:on 4:on 5:on 6:off
iscsi 0:off 1:off 2:off 3:on 4:on 5:on 6:off
iscsid 0:off 1:off 2:off 3:on 4:on 5:on 6:off
lvm2-monitor 0:off 1:on 2:on 3:on 4:on 5:on 6:off
mdmonitor 0:off 1:off 2:on 3:on 4:on 5:on 6:off
multipathd 0:off 1:off 2:off 3:off 4:off 5:off 6:off
netconsole 0:off 1:off 2:off 3:off 4:off 5:off 6:off
netfs 0:off 1:off 2:off 3:on 4:on 5:on 6:off
network 0:off 1:off 2:on 3:on 4:on 5:on 6:off
nginx 0:off 1:off 2:on 3:on 4:on 5:on 6:off
postfix 0:off 1:off 2:on 3:on 4:on 5:on 6:off
rdisc 0:off 1:off 2:off 3:off 4:off 5:off 6:off
restorecond 0:off 1:off 2:off 3:off 4:off 5:off 6:off
rsyslog 0:off 1:off 2:on 3:on 4:on 5:on 6:off
saslauthd 0:off 1:off 2:off 3:off 4:off 5:off 6:off
sshd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
udev-post 0:off 1:on 2:on 3:on 4:on 5:on 6:off
2、清除文件描述符
###建议先备份一下###[[email protected]-it ~]# ll /software/nginx/sbin/nginx -h
-rwxr-xr-x.1 root root 2.9MJun800:02/software/nginx/sbin/nginx
[[email protected]-it ~]# strip /software/nginx/sbin/nginx
[[email protected]-it ~]# ll /software/nginx/sbin/nginx -h
-rwxr-xr-x.1 root root 2.6MJun801:54/software/nginx/sbin/nginx
2、优化写磁盘操作
####重新挂载当前分区,不记录Nginx对文件访问的时间修改####
mount -o defaults,noatime,nodiratime -o remount /dev/sda1
3、优化文件描述符
####修改配置文件####[[email protected]-it ~]# egrep -v "^#|^$"/etc/security/limits.conf
*- nofile 65535*- nproc 65535[[email protected]-it ~]# su -[[email protected]-it ~]# ulimit -u
65535[[email protected]-it ~]# ulimit -n
65535
4、优化内核参数
[[email protected]-it ~]# cat >/etc/sysctl.conf<
时间: 2024-10-05 21:47:44