############ 安装nginx
yum install -y pcre pcre-devel zlib zlib-devel openssl openssl-devel autoconf automake make gcc-c++
useradd -s /sbin/nologin nginx
cd /usr/local/src
wget http://nginx.org/download/nginx-1.18.0.tar.gz
tar -xf nginx-1.18.0.tar.gz
cd nginx-1.18.0
./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_realip_module --with-http_stub_status_module --with-http_gzip_static_module --with-http_ssl_module --with-http_flv_module --with-stream --with-threads --with-stream_realip_module --with-stream_ssl_module --with-file-aio
make && make install
------- 配置环境变量 ----------
cat <<'EOF' > /etc/profile.d/nginx.sh
export NGINX_HOME=/usr/local/nginx
export PATH=$NGINX_HOME/sbin:$PATH
EOF
source /etc/profile
-------- 配置成系统服务 ------------
cat <<EOF > /usr/lib/systemd/system/nginx.service
[Unit]
Description=nginx - high performance web server
Documentation=http://nginx.org/en/docs/
After=network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
ExecStartPre=/usr/local/nginx/sbin/nginx -t -c /usr/local/nginx/conf/nginx.conf
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