nginx_setup_debian.sh
时间:2009-01-14 来源:h_xin8211
#!/bin/bash
##########################
#
# nginx_setup_debian
#
##########################
aptitude update
aptitude install gcc g++ make build-essential libpcre3 libpcre3-dev libpcrecpp0 libssl-dev zlib1g-dev
# add user and group
groupadd nginx
useradd -g nginx -d /home/nginx -s /sbin/nologin nginx
#download and setup
wget http://sysoev.ru/nginx/nginx-0.7.30.tar.gz
tar zxfv nginx-0.7.30.tar.gz
cd nginx-0.7.30
./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_ssl_module
make
make install
cp /usr/local/nginx/conf/nginx.conf /usr/local/nginx/conf/nginx.conf.bak
#Optimized Linux kernel parameters
cat >> /etc/sysctl << "EOF"
net.ipv4.tcp_fin_timeout = 30
net.ipv4.tcp_keepalive_time = 300
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_tw_recycle = 1
net.ipv4.ip_local_port_range = 5000 65000
EOF
/sbin/sysctl -p
cat >> /etc/rc.local << "EOF"
ulimit -SHn 51200
/usr/local/nginx/sbin/nginx
EOF
# start nginx
/usr/local/nginx/sbin/nginx