Linux下nginx一键安装shell脚本
先从http://wiki.nginx.org/RedHatNginxInitScript下载init.d.nginx启动文件到当前目录,修改程序安装目录
#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
# Check if user is root
if [ $(id -u) != "0" ]; then
echo "Error: You must be root to run this script, please use root to install this shell script"
exit 1
fi
groupadd www
useradd -s /sbin/nologin -g www www
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.21.tar.gz
tar zxvf pcre-8.21.tar.gz
cd pcre-8.21/
./configure
make && make install
cd ../
ldconfig
wget http://nginx.org/download/nginx-1.2.7.tar.gz
tar zxvf nginx-1.2.7.tar.gz
cd nginx-1.2.7/
./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module --with-ipv6
make && make install
cd ../
cp init.d.nginx /etc/init.d/nginx
chmod +x /etc/init.d/nginx
chkconfig --level 345 nginx on
/etc/init.d/nginx start
ps aux |grep nginx