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"
  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值