centos7 编译安装nginx脚本

#!/bin/sh

#centos7 自动编译安装nginx
#安装条件 :centos7系统 安装nginx v1.19.4
#个人安装使用


yum install -y tar wget make cmake gcc gcc-c++ pcre pcre-devel zlib zlib-devel openssl openssl-devel
#若不存在需要安装
yum install kernel-headers kernel-devel gcc make -y


#1
rm -rf nginx-1.19.4.tar.gz
rm -rf nginx-1.19.4
wget http://nginx.org/download/nginx-1.19.4.tar.gz
if [ $? -eq 0 ]
then
echo -e "\033[32m '>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 1 finish >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>' \033[0m"
else
echo -e "\033[31m '__________________________________1 bad ,and EXIT' \033[0m"
exit 1
fi

#2
tar -zxvf nginx-1.19.4.tar.gz
if [ $? -eq 0 ]
then
echo -e "\033[32m '>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 2 finish >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>' \033[0m"
else
echo -e "\033[31m '__________________________________2 bad ,and EXIT' \033[0m"
exit 1
fi

#3
cd nginx-1.19.4
if [ $? -eq 0 ]
then
echo -e "\033[32m '>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 3 finish >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>' \033[0m"
else
echo -e "\033[31m '__________________________________3 bad ,and EXIT' \033[0m"
exit 1
fi

#4
#添加status模块和ssl模块
./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module
if [ $? -eq 0 ]
then
echo -e "\033[32m '>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 4 finish >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>' \033[0m"
else
echo -e "\033[31m '__________________________________4 bad ,and EXIT' \033[0m"
exit 1
fi

#5
make -j4 && make install
if [ $? -eq 0 ]
then
echo -e "\033[32m '>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 5 finish >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>' \033[0m"
else
echo -e "\033[31m '__________________________________5 bad ,and EXIT' \033[0m"
exit 1
fi

#6
echo '###################################### check ######################################'
/usr/local/nginx/sbin/nginx -t
if [ $? -eq 0 ]
then
echo -e "\033[32m '>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 6 finish >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>' \033[0m"
else
echo -e "\033[31m '__________________________________6 bad ,and EXIT' \033[0m"
exit 1
fi

 

posted @ 2022-02-24 14:37  tangshow  阅读(115)  评论(0编辑  收藏  举报