shell编译安装nginx脚本

1、下载的地址为搜狐镜像
2、版本只选择了几个作为测试,可以自行添加或删除
3、nginx模块安装可以进行自行添加或删除

[root@localhost shell]# cat nginx_install.sh
#!/bin/bash
ping -c 1 114.114.114.114 > /dev/null 2>&1
if [ $? -eq 0 ]
then
	echo 网络正常
else
	echo 网络连接异常
	exit 1
fi
yum install -y  wget gcc pcre-devel net-tools gcc-c++ openssl-devel zlib-devel zlib
# select nginx version
get_version()
{
	read -p "please input version (1.5.0 or 1.6.0 or 1.7.0):" Version
	case $Version in
	1.5.0)
		wget http://mirrors.sohu.com/nginx/nginx-1.5.0.tar.gz
		tar -zvxf nginx-1.5.0.tar.gz
		cd nginx-1.5.0
	;;
	1.6.0)
		wget http://mirrors.sohu.com/nginx/nginx-1.6.0.tar.gz
		tar -zvxf nginx-1.6.0.tar.gz
		cd nginx-1.6.0
	;;
	1.7.0)
		wget http://mirrors.sohu.com/nginx/nginx-1.7.0.tar.gz
		tar -zvxf nginx-1.7.0.tar.gz
		cd nginx-1.7.0
	;;
	*)
		echo "please try again"
		get_version
	;;
	esac
}
get_version
# addgroup adduser
groupadd -g 1001 nginx
useradd -u 900 nginx -g nginx -s /sbin/nologin
# install
./configure --prefix=/usr/local/nginx --with-http_dav_module --with-http_stub_status_module --with-http_addition_module --with-http_sub_module --with-http_flv_module --with-http_mp4_module --with-http_ssl_module --with-http_gzip_static_module --user=nginx --group=nginx
make && make install
ln -s /usr/local/nginx/sbin/nginx /usr/local/sbin
nginx -t
nginx
netstat -lnpt |grep 80
echo "nginx install finish"

你可能感兴趣的:(shell编译安装nginx脚本)