1
2
| 创建nginx用户
useradd -s /bin/false -M nginx
|
1
2
3
4
5
6
| 进入安装目录 /opt下
cd /opt
下载nginx(官方链接) #以1.21.6版本为例
wget https://nginx.org/download/nginx-1.21.6.tar.gz
解压
tar -xvf nginx-1.21.6.tar.gz
|
1
2
3
4
| 下载并解压 所需的三个依赖包 openssl zlib pcre (仅提供官网)
https://www.openssl.org #openssl-3.0.5
https://www.zlib.net #zlib-1.2.12
http://www.pcre.org #pcre-8.43
|
1
2
| 进入nginx目录
cd nginx-1.21.6
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
| 运行脚本
./configure \
--prefix=/opt/nginx \
--sbin-path=/opt/nginx/sbin/nginx \
--conf-path=/opt/nginx/nginx.conf \
--error-log-path=/opt/nginx/logs/error.log \
--http-log-path=/opt/nginx/logs/access.log \
--pid-path=/opt/nginx/run/nginx.pid \
--lock-path=/opt/nginx/lock/nginx.lock \
--user=nginx \
--group=nginx \
--with-http_ssl_module \
--with-http_realip_module \
--with-http_stub_status_module \
--with-http_gzip_static_module \
--with-pcre=../pcre-8.43 \
--with-zlib=../zlib-1.2.12 \
--with-openssl=../openssl-3.0.5 \
--with-debug \
--http-client-body-temp-path=/opt/nginx/client_body \
--http-proxy-temp-path=/opt/nginx/proxy \
--http-fastcgi-temp-path=/opt/nginx/fastcgi \
--http-uwsgi-temp-path=/opt/nginx/uwsgi \
--http-scgi-temp-path=/opt/nginx/scgi \
--with-stream
|
注意:这三条分别指向刚刚下载的三个依赖包的目录!!!
1
2
3
| --with-pcre=../pcre-8.43 \
--with-zlib=../zlib-1.2.12 \
--with-openssl=../openssl-3.0.5 \
|
进行编译安装
make && make install