centos7离线安装nginx ssl

1 将nginx的安装包上传到服务器的/home/software目录

然后输入命令 tar -zxvf nginx-1.21.5.tar.gz 命令将其解压
输入命令 mkdir -p /usr/local/nginx 创建nginx的安装目录
输入 cd nginx-1.21.5/ 进入nginx的解压目录

然后运行./configure --prefix=/usr/local/nginx --with-http_ssl_module命令
如果报错

./configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using --with-pcre=<path> option.

  

则是缺少openssl

安装openssl

 下载OpenSSL源代码 首先,您需要从OpenSSL官方网站(https://www.openssl.org/)下载最新的OpenSSL源代码,并将其解压缩到您想要安装Nginx的目录中。

 

然后执行: ./configure --with-http_ssl_module --with-openssl=/home/software/openssl-3.1.0 

make
make install

执行make的时候有可能出错

 

原因是没有perl环境,执行命令 perl -v 查看是否有perl环境
离线安装perl
下载 Perl 安装包

首先,您需要从 Perl 官方网站(https://www.perl.org/)下载 Perl 的安装包,并将其复制到目标计算机上。

注意:请确保您下载的安装包与您的操作系统和架构相对应。

解压 Perl 安装包

解压缩 Perl 安装包到您选择的目录中(我上传到/home/software目录),例如:

./Configure -des -Dprefix=/path/to/perl
make
make test
make install

注意:将“/path/to/perl”替换为您想要安装 Perl 的目录。

 

配置 PATH 环境变量

添加 Perl 的二进制文件路径到系统的 PATH 环境变量中。您可以在您的 shell 配置文件(例如“~/.bashrc”)中添加以下行:

export PATH=/path/to/perl/bin:$PATH
然后,运行以下命令使更改生效:
source ~/.bashrc
确认 Perl 已成功安装并可用:
perl -v

 

然后就可以继续执行nginx的安装步骤了

然后运行./configure --prefix=/usr/local/nginx --with-http_ssl_module命令
然后分别运行
make
make install
nginx启动命令/usr/local/nginx/sbin/nginx
nginx停止命令/usr/local/nginx/sbin/nginx -s stop

 

posted on 2023-03-17 18:40  james-roger  阅读(589)  评论(0编辑  收藏  举报