1. 去nginx官网 https://nginx.org/en/download.html 下载 Stable version 版本的, nginx 的历史版本可以在这里下载 https://nginx.org/download
例如: https://nginx.org/download/nginx-1.26.1.tar.gz
2. 然后解压, 并修改解压后的目录名称为 nginx
3. 在 nginx 目录下执行命令, 如需添加其他模块请参考 https://nginx.org/en/docs/configure.html
./configure \
--prefix=/opt/nginx-1.26.1 \
--with-http_ssl_module \
--with-openssl=../openssl-3.3.1 \
--with-pcre=../pcre2-10.44 \
--with-zlib=../zlib-1.3.1
注意需要提前下载所需的相关包, openssl, pcre2, zlib 并解压
3. 继续执行命令
make
4. 继续执行命令
make install
最后就可以在 /opt/nginx-1.26.1 目录看到编译完成的 nginx