#!/bin/bash#Nginx版本NGINX_V=1.20.0#Nginx下载目录TMP_DIR=/tmp #Nginx装置目录INSTALL_DIR=/usr/localfunction install_nginx() {#下载依赖yum -y install gcc gcc-c++ automake pcre pcre-devel zlib zlib-devel openssl openssl-devel#下载Nginxcd ${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.gzmv nginx-${NGINX_V} nginx;cd nginx;#预编译配置./configure --prefix=/usr/local/nginx --with-http_ssl_module --with-http_stub_status_modulesleep 2s#编译装置make && make install#以服务启动cd /usr/lib/systemd/system;cat > nginx.service <<EOF[Unit]Description=nginx - high performance web serverDocumentation=http://nginx.org/en/docs/After=network.target remote-fs.target nss-lookup.target  [Service]Type=forkingPIDFile=/usr/local/nginx/logs/nginx.pidExecStartPre=/usr/local/nginx/sbin/nginx -t -c /usr/local/nginx/conf/nginx.confExecStart=/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.confExecReload=/bin/kill -s HUP $MAINPIDExecStop=/bin/kill -s QUIT $MAINPIDPrivateTmp=true  [Install]WantedBy=multi-user.targetEOFsystemctl restart firewalld;firewall-cmd --reload;systemctl start nginx;systemctl enable nginx;systemctl status nginx.service;}