配置环境
系统版本:centos7
nginx版本: nginx-1.14.2
一键安装脚本源码
1 #!/bin/bash 2 # 关闭防火墙与selinux 3 systemctl stop firewalld.service && setenforce 0 4 # 安装nginx 5 echo "开始安装nginx" 6 # 安装nginx的依赖包 7 echo "安装依赖包" 8 yum -y install gcc gcc-c++ pcre-devel zlib-devel >/dev/null 9 # 解压nginx源码包_版本不一致不写版本号 10 echo "解压nginx源码包" 11 tar -zxf nginx-1.14.2.tar.gz 12 # 进入nginx包 13 # 进入安装包_并检测_编译_安装 14 cd nginx-1.14.2 15 # 检测安装环境 16 ./configure >/dev/null 17 # 编译并安装 18 make && make install >/dev/null 19 echo "启动nginx" 20 /usr/local/nginx/sbin/nginx 21 curl 127.0.0.1 >/dev/null 22 if [ $? -eq 0 ];then 23 echo "nginx安装成功并启动" 24 else 25 echo "nginx安装失败" 26 27 28 echo "----------------------------------------------------------"