**1.下载源码包**
http://nginx.org/en/download.html
```
wget http://nginx.org/download/nginx-1.22.0.tar.gz
```
**2.编译源码包**
```
useradd -s /sbin/nologin nginx
mkdir /var/cache/nginx
yum -y install gcc-c++ zlib zlib-devel openssl openssl-devel pcre pcre-devel openssl openssl-devel gcc
```
```
tar -zxvf nginx-1.22.0.tar.gz -C /usr/local/
cd /usr/local/nginx-1.22.0
```
```
./configure \
--prefix=/etc/nginx \
--sbin-path=/usr/sbin/nginx \
--conf-path=/etc/nginx/nginx.conf \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--pid-path=/var/run/nginx.pid \
--lock-path=/var/run/nginx.lock \
--http-client-body-temp-path=/var/cache/nginx/client_temp \
--http-proxy-temp-path=/var/cache/nginx/proxy_temp \
--http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp \
--http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp \
--http-scgi-temp-path=/var/cache/nginx/scgi_temp \
--user=nginx \
--group=nginx \
--with-http_gunzip_module \
--with-http_gzip_static_module \
--with-stream
make && make install
```