1、配置YUM源、安装


 [nginx] name=nginx repo baseurl=http://nginx.org/packages/OS/OSRELEASE/$basearch/ gpgcheck=0 enabled=1 

   

 Replace “OS” with “rhel” or “centos”, depending on the distribution used, and “OSRELEASE” with “5” or “6”, for 5.x or 6.x versions, respectively. 

   

 [nginx] name=nginx repo baseurl=http://nginx.org/packages/rhel/5/$basearch/ gpgcheck=0 enabled=1 

   

 yum install nginx 

   

 这样安装完成后,nginx是一个服务,而且自动启动。 

   

 2、LOG配置与调整 

 默认LOG是在/var/log/nginx/中 

 有两个,一个是access.log,一个是error.log 

 默认的nginx.conf文件在/etc/nginx/nginx.conf 

   

 把log放入内存: 

 access_log /dev/shm/access.log main; 

   

 3、LOG的分割

 logspliter.sh

 #!/bin/bash

 log_dir="/dev/shm/"

 date_file=`date +%g%m%d%H%M`

 /bin/mv ${log_dir}/nginx_access.log ${log_dir}/$date_file}.trn

 kill -USR1 `cat /var/run/nginx.pid`

   

   

 4、定期调用 by crontab

 crontab -e

 加入

 * * * * * /logspliter/logspliter.sh

 m h d M w 分钟 小时 天 月 星期几 

  

 5、协议栈的调整 在/etc/sysctl.conf中加入

 

 net.core.rmem_max = 374217728

 net.core.wmem_max = 374217728

 net.ipv4.tcp_tw_reuse = 1

 net.ipv4.tcp_tw_recycle = 1

 net.ipv4.tcp_fin_timeout = 1

 可以增大网络的稳定性和高吞吐能力

  

 sysctl -p