Linux环境OpenSSL安装

本文详细介绍了如何在64位系统上从源码编译并安装OpenSSL,包括解压源码包、配置编译参数、解决常见错误及最终的安装过程。特别强调了如何避免在链接阶段遇到的32位库问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

原文地址:https://blog.youkuaiyun.com/Tzhennan/article/details/80554653

官方下载地址:

https://www.openssl.org/source/

#解压

$ tar -zxvf openssl-1.1.0h.tar.gz

$ cd openssl-1.1.0h

#配置 

$ sudo ./config --prefix=/usr/local/openssl

该步骤出现如下警告 Configured for darwin-i386-cc. wanzhihuideMacBook-Pro:openssl-1.1.0h wanzhihui$ sudo ./config --prefix=/usr/local/ --openssldir=/usr/local/openssl darwin64-x86_64-cc Operating system: i686-apple-darwinDarwin Kernel Version 15.0.0: Sat Sep 19 15:53:46 PDT 2015; root:xnu-3247.10.11~1/RELEASE_X86_64 WARNING! If you wish to build 64-bit library, then you have to          invoke './Configure darwin64-x86_64-cc' *manually*.          You have about 5 seconds to press Ctrl-C to abort.

openssl/config脚本会根据$KERNEL_BITS来判断是否开启x86_64编译,默认是不开启的,所以你生成的openssl库文件是32位的,最后静态链接到nginx会出错。

解决方法: 找到makefile将里面的PLATFORM=dist改成 PLATFORM=darwin64-x86_64-cc

#配置、编译和安装

$ export KERNEL_BITS=64

$ sudo ./config darwin64-x86_64-cc  --prefix=/usr/local/openssl

$ sudo make

$ sudo make install

#查看版本

$ openssl version

不编译64位的在安装nginx时会报链接错误: -L/usr/local/lib -lpcre /usr/local/openssl/lib/libssl.a /usr/local/openssl/lib/libcrypto.a -lz ld: warning: ignoring file /usr/local/openssl/lib/libssl.a, file was built for archive which is not the architecture being linked (x86_64): /usr/local/openssl/lib/libssl.a ld: warning: ignoring file /usr/local/openssl/lib/libcrypto.a, file was built for archive which is not the architecture being linked (x86_64): /usr/local/openssl/lib/libcrypto.a Undefined symbols for architecture x86_64:   "_ASN1_GENERALIZEDTIME_print", referenced from:       _ngx_ssl_stapling_ocsp_handler in ngx_event_openssl_stapling.o   "_ASN1_d2i_bio", referenced from:       _ngx_ssl_stapling in ngx_event_openssl_stapling.o   "_BIO_ctrl", referenced from:       _ngx_ssl_get_raw_certificate in ngx_event_openssl.o       _ngx_ssl_get_serial_number in ngx_event_openssl.o       _ngx_ssl_stapling_ocsp_handler in ngx_event_openssl_stapling.o   "_BIO_free"

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值