ubuntu 22.04 编译安装nignx 报错 openssl 问题

news2025/6/6 13:25:25

前言

在这里插入图片描述

Ubuntu 20.04 中安装 Nginx (通过传包编译的方式)、开启关闭防火墙、开放端口号

在ubuntu 22.04.3 服务器上照着上面的文章 通过传包编译的方式安装nginx-1.18.0 的时候报错,报错内容如下:

src/event/ngx_event_openssl.c: In function ‘ngx_ssl_load_certificate_key’:
src/event/ngx_event_openssl.c:721:9: error:ENGINE_by_idis deprecated: Since OpenSSL 3.0 [-Werror=deprecated-declarations]
  721 |         engine = ENGINE_by_id((char *) p);
      |         ^~~~~~
In file included from src/event/ngx_event_openssl.h:22,
                 from src/core/ngx_core.h:84,
                 from src/event/ngx_event_openssl.c:9:
/usr/include/openssl/engine.h:336:31: note: declared here
  336 | OSSL_DEPRECATEDIN_3_0 ENGINE *ENGINE_by_id(const char *id);
      |                               ^~~~~~~~~~~~
src/event/ngx_event_openssl.c:730:9: error:ENGINE_load_private_keyis deprecated: Since OpenSSL 3.0 [-Werror=deprecated-declarations]
  730 |         pkey = ENGINE_load_private_key(engine, (char *) last, 0, 0);
      |         ^~~~
In file included from src/event/ngx_event_openssl.h:22,
                 from src/core/ngx_core.h:84,
                 from src/event/ngx_event_openssl.c:9:
/usr/include/openssl/engine.h:638:11: note: declared here
  638 | EVP_PKEY *ENGINE_load_private_key(ENGINE *e, const char *key_id,
      |           ^~~~~~~~~~~~~~~~~~~~~~~
src/event/ngx_event_openssl.c:734:13: error:ENGINE_freeis deprecated: Since OpenSSL 3.0 [-Werror=deprecated-declarations]
  734 |             ENGINE_free(engine);
      |             ^~~~~~~~~~~
In file included from src/event/ngx_event_openssl.h:22,
                 from src/core/ngx_core.h:84,
                 from src/event/ngx_event_openssl.c:9:
/usr/include/openssl/engine.h:493:27: note: declared here
  493 | OSSL_DEPRECATEDIN_3_0 int ENGINE_free(ENGINE *e);
      |                           ^~~~~~~~~~~
src/event/ngx_event_openssl.c:738:9: error:ENGINE_freeis deprecated: Since OpenSSL 3.0 [-Werror=deprecated-declarations]
  738 |         ENGINE_free(engine);
      |         ^~~~~~~~~~~
In file included from src/event/ngx_event_openssl.h:22,
                 from src/core/ngx_core.h:84,
                 from src/event/ngx_event_openssl.c:9:
/usr/include/openssl/engine.h:493:27: note: declared here
  493 | OSSL_DEPRECATEDIN_3_0 int ENGINE_free(ENGINE *e);
      |                           ^~~~~~~~~~~
src/event/ngx_event_openssl.c: In function ‘ngx_ssl_dhparam’:
src/event/ngx_event_openssl.c:1334:5: error:PEM_read_bio_DHparamsis deprecated: Since OpenSSL 3.0 [-Werror=deprecated-declarations]
 1334 |     dh = PEM_read_bio_DHparams(bio, NULL, NULL, NULL);
      |     ^~
In file included from /usr/include/openssl/ssl.h:36,
                 from src/event/ngx_event_openssl.h:15,
                 from src/core/ngx_core.h:84,
                 from src/event/ngx_event_openssl.c:9:
/usr/include/openssl/pem.h:469:1: note: declared here
  469 | DECLARE_PEM_rw_attr(OSSL_DEPRECATEDIN_3_0, DHparams, DH)
      | ^~~~~~~~~~~~~~~~~~~
src/event/ngx_event_openssl.c:1344:5: error:DH_freeis deprecated: Since OpenSSL 3.0 [-Werror=deprecated-declarations]
 1344 |     DH_free(dh);
      |     ^~~~~~~
In file included from /usr/include/openssl/dsa.h:51,
                 from /usr/include/openssl/x509.h:37,
                 from /usr/include/openssl/ssl.h:31,
                 from src/event/ngx_event_openssl.h:15,
                 from src/core/ngx_core.h:84,
                 from src/event/ngx_event_openssl.c:9:
/usr/include/openssl/dh.h:204:28: note: declared here
  204 | OSSL_DEPRECATEDIN_3_0 void DH_free(DH *dh);
      |                            ^~~~~~~
src/event/ngx_event_openssl.c: In function ‘ngx_ssl_error’:
src/event/ngx_event_openssl.c:3039:13: error:ERR_peek_error_line_datais deprecated: Since OpenSSL 3.0 [-Werror=deprecated-declarations]
 3039 |             n = ERR_peek_error_line_data(NULL, NULL, &data, &flags);
      |             ^
In file included from src/event/ngx_event_openssl.h:16,
                 from src/core/ngx_core.h:84,
                 from src/event/ngx_event_openssl.c:9:
/usr/include/openssl/err.h:425:15: note: declared here
  425 | unsigned long ERR_peek_error_line_data(const char **file, int *line,
      |               ^~~~~~~~~~~~~~~~~~~~~~~~
src/event/ngx_event_openssl.c: In function ‘ngx_ssl_session_ticket_key_callback’:
src/event/ngx_event_openssl.c:3949:9: error:HMAC_Init_exis deprecated: Since OpenSSL 3.0 [-Werror=deprecated-declarations]
 3949 |         if (HMAC_Init_ex(hctx, key[0].hmac_key, size, digest, NULL) != 1) {
      |         ^~
In file included from /usr/include/openssl/ssl.h:37,
                 from src/event/ngx_event_openssl.h:15,
                 from src/core/ngx_core.h:84,
                 from src/event/ngx_event_openssl.c:9:
/usr/include/openssl/hmac.h:43:27: note: declared here
   43 | OSSL_DEPRECATEDIN_3_0 int HMAC_Init_ex(HMAC_CTX *ctx, const void *key, int len,
      |                           ^~~~~~~~~~~~
src/event/ngx_event_openssl.c:3993:9: error:HMAC_Init_exis deprecated: Since OpenSSL 3.0 [-Werror=deprecated-declarations]
 3993 |         if (HMAC_Init_ex(hctx, key[i].hmac_key, size, digest, NULL) != 1) {
      |         ^~
In file included from /usr/include/openssl/ssl.h:37,
                 from src/event/ngx_event_openssl.h:15,
                 from src/core/ngx_core.h:84,
                 from src/event/ngx_event_openssl.c:9:
/usr/include/openssl/hmac.h:43:27: note: declared here
   43 | OSSL_DEPRECATEDIN_3_0 int HMAC_Init_ex(HMAC_CTX *ctx, const void *key, int len,
      |                           ^~~~~~~~~~~~
src/event/ngx_event_openssl.c: In function ‘ngx_openssl_engine’:
src/event/ngx_event_openssl.c:5124:5: error:ENGINE_by_idis deprecated: Since OpenSSL 3.0 [-Werror=deprecated-declarations]
 5124 |     engine = ENGINE_by_id((char *) value[1].data);
      |     ^~~~~~
In file included from src/event/ngx_event_openssl.h:22,
                 from src/core/ngx_core.h:84,
                 from src/event/ngx_event_openssl.c:9:
/usr/include/openssl/engine.h:336:31: note: declared here
  336 | OSSL_DEPRECATEDIN_3_0 ENGINE *ENGINE_by_id(const char *id);
      |                               ^~~~~~~~~~~~
src/event/ngx_event_openssl.c:5132:5: error:ENGINE_set_defaultis deprecated: Since OpenSSL 3.0 [-Werror=deprecated-declarations]
 5132 |     if (ENGINE_set_default(engine, ENGINE_METHOD_ALL) == 0) {
      |     ^~
In file included from src/event/ngx_event_openssl.h:22,
                 from src/core/ngx_core.h:84,
                 from src/event/ngx_event_openssl.c:9:
/usr/include/openssl/engine.h:708:27: note: declared here
  708 | OSSL_DEPRECATEDIN_3_0 int ENGINE_set_default(ENGINE *e, unsigned int flags);
      |                           ^~~~~~~~~~~~~~~~~~
src/event/ngx_event_openssl.c:5137:9: error:ENGINE_freeis deprecated: Since OpenSSL 3.0 [-Werror=deprecated-declarations]
 5137 |         ENGINE_free(engine);
      |         ^~~~~~~~~~~
In file included from src/event/ngx_event_openssl.h:22,
                 from src/core/ngx_core.h:84,
                 from src/event/ngx_event_openssl.c:9:
/usr/include/openssl/engine.h:493:27: note: declared here
  493 | OSSL_DEPRECATEDIN_3_0 int ENGINE_free(ENGINE *e);
      |                           ^~~~~~~~~~~
src/event/ngx_event_openssl.c:5142:5: error:ENGINE_freeis deprecated: Since OpenSSL 3.0 [-Werror=deprecated-declarations]
 5142 |     ENGINE_free(engine);
      |     ^~~~~~~~~~~
In file included from src/event/ngx_event_openssl.h:22,
                 from src/core/ngx_core.h:84,
                 from src/event/ngx_event_openssl.c:9:
/usr/include/openssl/engine.h:493:27: note: declared here
  493 | OSSL_DEPRECATEDIN_3_0 int ENGINE_free(ENGINE *e);
      |                           ^~~~~~~~~~~
cc1: all warnings being treated as errors
make[1]: *** [objs/Makefile:842:objs/src/event/ngx_event_openssl.o] 错误 1
make[1]: 离开目录“/home/user/下载/nginx-1.18.0”
make: *** [Makefile:8:build] 错误 2

问题总结

因为之前安装 该方式已经安装了 很多遍nginx 不应该 出现该问题的。尝试安装了几遍都不行,几经辗转终于通过gpt找到了问题所在,并解决。

由于 Nginx 的源码使用了 OpenSSL 中已经在 3.0 版本废弃的 API,而你的系统使用的是 OpenSSL 3.0+,而且 gcc 把所有 warning 都当成 error (-Werror) 处理了,所以编译直接失败。

解决方法

一、升级nginx

下载最新版本的nginx解决兼容性问题,源码是 nginx-1.18.0,这个版本比较旧,不兼容 OpenSSL 3。建议升级到 1.21+(长期支持版)或最新稳定版(比如 1.24.0)

重新下载更高版本的nginx,安装步骤还是按照文章中的来,我才用的也是这种方法。问题解决了

二、去掉-werror

临时避开OpenSSL警告,风险较高

如果还要用 nginx-1.18.0,可以通过 关闭 OpenSSL 废弃函数的警告错误 来绕过:

./configure 之后、make 之前,修改编译参数来去掉 -Werror

sed -i 's/-Werror//g' objs/Makefile

再执行make

make
sudo make install

这会忽略掉 OpenSSL 的废弃警告(不推荐长期这样使用,安全性会下降)。

三、编译OpenSSL 1.1.1

如果不想换 Nginx,可以降级 OpenSSL,但 不建议全局替换系统 OpenSSL,推荐指定路径编译使用:

# 下载 OpenSSL 1.1.1
wget https://www.openssl.org/source/openssl-1.1.1w.tar.gz
tar -zxvf openssl-1.1.1w.tar.gz
cd openssl-1.1.1w
./config
make
sudo make install

# 编译 Nginx 时指定 OpenSSL 路径
cd nginx-1.18.0
./configure --with-http_ssl_module --with-openssl=/path/to/openssl-1.1.1w
make

注意:本人使用的是第一种 方法解决的,二三两种是gpt给出的解决方法,是否有效还待验证。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/2398617.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

线程相关面试题

提示:线程相关面试题,持续更新中 文章目录 一、Java线程池1、Java线程池有哪些核心参数,分别有什么的作用?2、线程池有哪些拒绝策略?3、说一说线程池的执行流程?4、线程池核心线程数怎么设置呢?4、Java线程…

pikachu通关教程-目录遍历漏洞(../../)

目录遍历漏洞也可以叫做信息泄露漏洞、非授权文件包含漏洞等. 原理:目录遍历漏洞的原理比较简单,就是程序在实现上没有充分过滤用户输入的../之类的目录跳转符,导致恶意用户可以通过提交目录跳转来遍历服务器上的任意文件。 这里的目录跳转符可以是../…

Maven-生命周期

目录 1.项目对象模型 2.依赖管理模型 3.仓库:用于存储资源,管理各种jar包 4.本地仓库路径 1.项目对象模型 2.依赖管理模型 3.仓库:用于存储资源,管理各种jar包 4.本地仓库路径

Matlab实现LSTM-SVM回归预测,作者:机器学习之心

Matlab实现LSTM-SVM回归预测,作者:机器学习之心 目录 Matlab实现LSTM-SVM回归预测,作者:机器学习之心效果一览基本介绍程序设计参考资料 效果一览 基本介绍 代码主要功能 该代码实现了一个LSTM-SVM回归预测模型,核心流…

Spring Boot 自动配置原理:从入门到精通

Spring Boot 的自动配置是其核心特性之一,它极大地简化了 Spring 应用的开发,让开发者可以专注于业务逻辑,而无需编写大量的配置代码。 本文将深入探讨 Spring Boot 自动配置的原理,帮助你理解其工作机制,并能灵活运用…

腾讯 ovCompose 开源,Kuikly 鸿蒙和 Compose DSL 开源,腾讯的“双”鸿蒙方案发布

近日,腾讯的 ovCompose 和 Kuikly 都发布了全新开源更新,其中 Kuikly 在之前我们聊过,本次 Kuikly 主要是正式开源鸿蒙支持部分和 Compose DSL 的相关支持,而 ovCompose 是腾讯视频团队基于 Compose Multiplatform 生态推出的跨平…

PYTHON调用讯飞C/C++动态库实现离线语音合成并且实时播放

语音合成(Text-to-Speech, TTS)技术在现代应用中扮演着越来越重要的角色,从智能客服到有声读物,从导航系统到辅助工具,TTS技术无处不在。本文将详细介绍如何使用Python结合科大讯飞的离线SDK实现一个本地化的语音合成系统。 技术背景 离线语…

黑马Java面试笔记之 消息中间件篇(RabbitMQ)

一. 消息丢失问题 RabbitMQ如何保证消息不丢失? 使用场景有: 异步发送(验证码、短信、邮件... )MYSQL和Redis,ES之间的数据同步分布式事务削峰填谷...... 消息丢失原因会有三种情况,分别分析一下 1.1 生…

Redisson学习专栏(五):源码阅读及Redisson的Netty通信层设计

文章目录 前言一、分布式锁核心实现:RedissonLock源码深度解析1.1 加锁机制:原子性与重入性实现1.2 看门狗机制:锁自动续期设计1.3 解锁机制:安全释放与通知1.4 锁竞争处理:等待队列与公平性1.5 容错机制:异…

结合 AI 生成 mermaid、plantuml 等图表

AI 画图 AI 画图并不是真的让 AI 画一个图片,而是让 AI 根据你的需求,生成对应的需求文本,再根据 “文本画图” 来生成图片。 Mermaid mermaid 支持流程图、时序图、架构图等等多种图片绘制。当然最终生成的效果和样式会根据不同的“文本代…

R语言使用随机过采样(Random Oversampling)平衡数据集

随机过采样(Random Oversampling)是一种用于平衡数据集的技术,常用于机器学习中处理类别不平衡问题。当某个类别的样本数量远少于其他类别时(例如二分类中的正负样本比例悬殊),模型可能会偏向多数类&#x…

【Kotlin】高阶函数Lambda内联函数

【Kotlin】简介&变量&类&接口 【Kotlin】数字&字符串&数组&集合 【Kotlin】高阶函数&Lambda&内联函数 【Kotlin】表达式&关键字 文章目录 函数还是属性高阶函数抽象和高阶函数实例: 函数作为参数的需求方法引用表达式更多使用场…

从0开始学vue:vue3和vue2的关系

一、版本演进关系1. 继承关系2. 版本生命周期 二、核心差异对比三、关键演进方向1. Composition API2. 性能优化 四、迁移策略1. 兼容构建模式2. 关键破坏性变更 五、生态演进1. 官方库升级2. 构建工具链 六、选型建议1. 新项目2. 现有项目 七、未来展望 一、版本演进关系 1. …

MySQL关系型数据库学习

学习参考链接:https://www.runoob.com/mysql/mysql-tutorial.html Windows 安装MYSQL服务端的步骤:https://www.runoob.com/w3cnote/windows10-mysql-installer.html 1. 概念学习 MySQL 是一种关联数据库管理系统,关联数据库将数据保存在不…

嵌入式硬件篇---龙芯2k1000串口

针对串口错误 “device reports readiness to read but returned no data (Device disconnected or multiple access on port?)” 的排查和解决方法 硬件方面 检查连接 确认串口设备(如串口线、连接的模块等)与龙芯设备之间的物理连接是否牢固&#xf…

谷歌地图苹果版v6.138.2 - 前端工具导航

谷歌地图(Google maps)苹果版是是由谷歌官方推出的一款手机地图应用。软件功能强大,支持本地搜索查找世界各地的地址、地点和商家;支持在街景视图中查看世界各地的360度全景图;支持查找乘坐火车、公交车和地铁的路线,或者查找步行…

NSSCTF [LitCTF 2025]test_your_nc

[复现]绕过学的还是太差了&#xff0c;多积累吧 ​​​​​​题目 题目: 给了一个python文件 #!/bin/python3 import osprint("input your command")blacklist [cat,ls, ,cd,echo,<,${IFS},sh,\\]while True:command input()for i in blacklist:if i in com…

Qwen3高效微调

高效微调 场景、模型、数据、算力 高效微调的应用场景 对话风格微调&#xff1a;高效微调可以用于根据特定需求调整模型的对话风格。例如&#xff0c;针对客服系统、虚拟助理等场景&#xff0c;模型可以通过微调来适应不同的 语气、礼貌程度 或 回答方式&#xff0c;从而在与…

Gitee Wiki:重塑关键领域软件研发的知识管理范式

在数字化转型浪潮席卷全球的当下&#xff0c;关键领域软件研发正面临前所未有的知识管理挑战。传统文档管理模式的局限性日益凸显&#xff0c;知识传承的断层问题愈发严重&#xff0c;团队协作效率的瓶颈亟待突破。Gitee Wiki作为新一代知识管理平台&#xff0c;正在通过技术创…

redis的哨兵模式和Redis cluster

目录 一. redis的主从复制 二. 哨兵模式 2.1 定义 2.2 作用 2.3 配置实例 三. Redis cluster 3.1 定义 3.2 作用 3.3 配置实例 1. 新建集群文件目录 2. 准备可执行文件到每个文件夹 3. 开启群集功能 4. 启动redis节点 5. 查看是否启动成功 6. 启动集群 7. 测试…