Centos7一键编译安装Nginx脚本

#!/bin/bash
#Nginx版本
NGINX_V=1.20.0
#Nginx下载目录
TMP_DIR=/tmp 
#Nginx安装目录
INSTALL_DIR=/usr/local

function install_nginx() {
#下载依赖
yum -y install gcc gcc-c++ automake pcre pcre-devel zlib zlib-devel openssl openssl-devel
#下载Nginx
cd ${TMP_DIR}
yum install -y wget && wget -c wget http://nginx.org/download/nginx-${NGINX_V}.tar.gz
#解压源码
tar -zxvf ${TMP_DIR}/nginx-${NGINX_V}.tar.gz
mv nginx-${NGINX_V} nginx;cd nginx;
#预编译配置
./configure --prefix=/usr/local/nginx --with-http_ssl_module --with-http_stub_status_module
sleep 2s
#编译安装
make && make install
#以服务启动
cd /usr/lib/systemd/system;
cat > nginx.service <

你可能感兴趣的:(shellcentos7)