#!/bin/bash #安装nginx脚本 ###################nginx编译安装脚本################################## systemctl staus nginx if [ $? -eq 0 ] ;then echo "nginx is installed" exit else test -d /root/nginx if [ $? -eq 0 ];then wget -P /root/nginx/ http://nginx.org/download/nginx-1.16.1.tar.gz mv /root/nginx/nginx-1.16.1.tar.gz /root/shell2/ tar -xvzf nginx-1.16.1.tar.gz cd nginx-1.16.1 ./configure --prefix=/usr/local/nginx2 && sleep 3 else mkdir -pv /root/nginx fi if [ $? -eq 0 ];then make -j 2 && sleep 3 && make install echo echo -e "\033[31m nginx install successful! \033[0m" ln -s /usr/local/nginx2/sbin/nginx /usr/bin/nginx clear nginx netstat -tanp | grep -w 80 echo -e "\033[31m nginx service is started \033[0m" else echo -e "\033[31m error \033[0m" fi fi
原文:https://www.cnblogs.com/ccbyk-90/p/12721096.html