yum install gd gd-devel -y
yum install pcre-devel openssl-devel libxml2-devel libxslt-devel -y
wget http://nginx.org/download/nginx-1.22.0.tar.gz //下载源码
tar -zxvf nginx-1.22.0.tar.gz //解压缩
cd nginx-1.22.0
//配置编译项
./configure --prefix=/usr/local/nginx --user=www --group=www --with-threads --with-file-aio --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_addition_module --with-http_xslt_module --with-http_image_filter_module --with-http_sub_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_auth_request_module --with-http_secure_link_module --with-http_degradation_module --with-http_slice_module --with-stream --with-stream_ssl_module --with-stream_realip_module --with-stream_ssl_preread_module
make && make install //编译并安装
编写启动脚本, 用于systemctl 管理.
[Unit]
Description=nginx - high performance web server
Documentation=http://nginx.org/en/docs/
After=network-online.target remote-fs.target nss-lookup.target
Wants=network-online.target
[Service]
Type=forking
ExecStart=/usr/local/nginx/sbin/nginx
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s TERM $MAINPID
[Install]
WantedBy=multi-user.target