
Nginx之手动离线安装及依赖包安装(pcre+zlib+openssl)
本文介绍了使用源码编译安装 Nginx 的详细步骤及编译参数信息。首先,提到了必需的依赖包,包括 PCRE、Zlib 和 OpenSSL,并提供了它们的下载链接。随后,详细说明了编译环境的准备工作,包括检查和安装 gcc、g++、以及 make。接着,逐步介绍了如何安装各个依赖包以及 Nginx 的过程,包括解压、配置、编译和安装。
nginx:http://nginx.org/en/download.html (版本:nginx-1.28.0.tar.gz)
pcre:http://www.pcre.org/ (版本:pcre2-10.45.zip)
zlib:http://www.zlib.net/ (版本:zlib-1.3.1.tar.gz)
oppenssl 3.5.2:https://www.openssl.org/source/ (版本:openssl-3.5.2.tar.gz)

所有包都放在 /opt/tools/nginx目录下 ( 权限777 )
检查Linux环境
- 检查gcc版本
gcc -v
gcc --version
- 检查g++版本
g++ -v
g++ --version
如果g++没有安装,则手动安装,安装依赖在此不多叙述,有疑问或问题的自行查询互联网,可输入关键字“Linux离线安装g++所需依赖”等等。
1)安装pcre
解压:unzip pcre2-10.45.zip
进入解压目录:cd pcre2-10.45
可要需要赋予权限 chmod 777 configure
配置:./configure
编译:make
安装:make install
2)安装OpenSSL
解压:tar -zxvf openssl-3.5.2.tar.gz
进入解压目录:cd openssl-3.5.2
可要需要赋予权限 chmod 777 config
配置:./config
编译:make
安装:make install
3)安装zlib
解压:tar -zxvf zlib-1.3.1.tar.gz
进入解压目录:cd zlib-1.3.1
可要需要赋予权限 chmod 777 configure
配置:./configure
编译:make
安装:make install
4)安装Nginx
解压:tar -zxvf nginx-1.28.0.tar.gz
进入解压目录:cd nginx-1.28.0
- 编译nginx
./configure --sbin-path=/usr/local/nginx/nginx --conf-path=/usr/local/nginx/nginx.conf --pid-path=/usr/local/nginx/nginx.pid --with-compat --with-debug --with-pcre-jit --with-http_ssl_module --with-http_stub_status_module --with-http_realip_module --with-http_auth_request_module --with-http_v2_module --with-http_dav_module --with-http_slice_module --with-threads --with-http_ssl_module --with-pcre=/opt/tools/nginx/pcre2-10.45 --with-zlib=/opt/tools/nginx/zlib-1.3.1 --with-openssl=/opt/tools/nginx/openssl-3.5.2
make && make install
5)检查nginx是否安装成功
cd /user/local/nginx
./nginx -V

- 检查nignx是否可以正常启动
./nginx
