cat > nginx-1.23.1-install.sh << 'eof'
#!/bin/bash
yum -y install cmake make gcc gcc-c++ pcre-devel zlib-devel openssl-devel
useradd -r -s /sbin/nologin www
wget https://repo.huaweicloud.com/nginx/nginx-1.23.1.tar.gz
# wget https://nginx.org/download/nginx-1.23.1.tar.gz #(官方)
tar -xf nginx-1.23.1.tar.gz
cd nginx-1.23.1
./configure \
--prefix=/usr/local/nginx \
--user=www --group=www \
--with-http_ssl_module \
--with-http_flv_module \
--with-http_gzip_static_module \
--with-http_realip_module \
--with-http_v2_module \
--with-http_sub_module \
--with-http_mp4_module \
--with-http_stub_status_module \
--with-http_gzip_static_module \
--with-pcre --with-stream \
--with-stream_ssl_module \
--with-stream_realip_module
make -j8 && make install
cat > /usr/lib/systemd/system/nginx.service << 'EOF'
[Unit]
Description=Nginx Web Server
After=network.target
[Service]
Type=forking
ExecStart=/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
ExecReload=/usr/local/nginx/sbin/nginx -s reload
ExecStop=/usr/local/nginx/sbin/nginx -s quit
PrivateTmp=true
[Install]
WantedBy=multi-user.target
EOF
systemctl start nginx
# systemctl reload nginx
eof
chmod +x nginx-1.23.1-install.sh
./nginx-1.23.1-install.sh