linux下安装linux openssl 编译编译时一直报错,如何解决?

Linux系统安装 OpenSSL两种方法
我的图书馆
Linux系统安装 OpenSSL两种方法
OpenSSL是一个开源的ssl技术,由于我需要使用php相关功能,需要获取https的文件所以必须安装这个东西了,下面我整理了两种关于OpenSSL安装配置方法。方法一,编译安装 OpenSSL
2.1、准备工作
系统版本:-10.10-Server-I386
更新源:apt-get update
升级软件:apt-get upgrade
更新系统:apt-get dist-upgrade
2.2、查看OpenSSL版本
部分 Linux 系统已默认安装了 OpenSSL 0.9.8,特别是 VPS 一般都安装了。
openssl version -a
2.3、安装基础编译环境
apt-get& install build-essential
2.3、编译安装 Zlib 库
wget http://zlib.net/zlib-1.2.5.tar.gz
tar -zxf zlib-1.2.5.tar.gz
cd zlib-1.2.5/
./configure --prefix=/usr/local
make && make install
2.4、卸载旧版本 OpenSSL
apt-get purge openssl
rm -rf /etc/ssl #删除配置文件
2.5、编译与安装 OpenSSL
prefix 是安装目录,openssldir 是配置文件目录,另外建议安装两次,shared 作用是生成动态连接库。
wget ftp://ftp.openssl.org/source/openssl-1.0.0c.tar.gz
tar -zxf openssl-1.0.0c.tar.gz
cd openssl-1.0.0c/
./config& --prefix=/usr/local --openssldir=/usr/local/ssl
make && make install
./config shared --prefix=/usr/local --openssldir=/usr/local/ssl
make clean
make && make install
OpenSSL库的安装
官网:http://www.openssl.org
下载页面:http://www.openssl.org/source/
选择最新版本下载
http://www.openssl.org/source/openssl-1.0.0a.tar.gz
tar –zxvf openssl-1.0.0d.tar.gz,解压目录为:openssl-1.0.0d
然后进入到 cd openssl-1.0.0d,进行配置、编译、安装
./configure或./config
make install
TA的最新馆藏
喜欢该文的人也喜欢本文讲的是linux下不重新编译apache添加安装mod_ssl模块和错误的处理方法,
1、进入apache源码目录。
2、进入module文件夹下的ssl目录。
3、找到oepnssl 的include路径,ubuntu系统是在/usr/include/openssl目录。
4、运行apxs
1、进入apache源码目录。
2、进入module文件夹下的ssl目录。
3、找到oepnssl 的include路径,ubuntu系统是在/usr/include/openssl目录。
4、运行apxs
root@v238:~/httpd-2.2.26/modules/ssl# /usr/local/apache2/bin/apxs -i -c -a -D HAVE_OPENSSL=1 -I /usr/include/openssl -lcrypto -lssl -ldl *.c
/usr/local/apr-httpd//build-1/libtool --silent --mode=compile gcc -prefer-pic -DLINUX -D_REENTRANT -D_GNU_SOURCE -g -O2 -pthread -I/usr/local/apache2/include -I/usr/local/apr-httpd//include/apr-1 -I/usr/local/apr-util-httpd/include/apr-1 -I/usr/include/openssl -DHAVE_OPENSSL=1 -c -o mod_ssl.lo mod_ssl.c && touch mod_ssl.slo
/usr/local/apr-httpd//build-1/libtool --silent --mode=compile gcc -prefer-pic -DLINUX -D_REENTRANT -D_GNU_SOURCE -g -O2 -pthread -I/usr/local/apache2/include -I/usr/local/apr-httpd//include/apr-1 -I/usr/local/apr-util-httpd/include/apr-1 -I/usr/include/openssl -DHAVE_OPENSSL=1 -c -o ssl_engine_config.lo ssl_engine_config.c && touch ssl_engine_config.slo
/usr/local/apache2/build/instdso.sh SH_LIBTOOL='/usr/local/apr-httpd//build-1/libtool' mod_ssl.la /usr/local/apache2/modules
/usr/local/apr-httpd//build-1/libtool --mode=install cp mod_ssl.la /usr/local/apache2/modules/
libtool: install: cp .libs/mod_ssl.so /usr/local/apache2/modules/mod_ssl.so
libtool: install: cp .libs/mod_ssl.lai /usr/local/apache2/modules/mod_ssl.la
libtool: install: cp .libs/mod_ssl.a /usr/local/apache2/modules/mod_ssl.a
libtool: install: chmod 644 /usr/local/apache2/modules/mod_ssl.a
libtool: install: ranlib /usr/local/apache2/modules/mod_ssl.a
libtool: finish: PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/lib/jvm/jdk1.7.0_45/bin:/sbin" ldconfig -n /usr/local/apache2/modules
----------------------------------------------------------------------
Libraries have been installed in:
/usr/local/apache2/modules
if you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
- add LIBDIR to the `LD_LIBRARY_PATH' environment variable
during execution
- add LIBDIR to the `LD_RUN_PATH' environment variable
during linking
- use the `-Wl,-rpath -Wl,LIBDIR' linker flag
- have your system administrator add LIBDIR to `/etc/ld.so.conf'
See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------
chmod 755 /usr/local/apache2/modules/mod_ssl.so
[activating module `ssl' in /usr/local/apache2/conf/httpd.conf]
5、检查配置、重启
执行成功后可以在httpd.conf配置文件中看到已经添加了mod_ssl模块,apache安装目录下的module中也创建了mod_ssl.so 文件。
root@v238:~/httpd-2.2.26/modules/ssl# /usr/local/apache2/bin/httpd -t
httpd: Could not reliably determine the server's fully qualified domain name, using 192.168.0.238 for ServerName
提示syntax ok,重启apache。
错误代码,error "Unrecognized SSL Toolkit!、declaration for parameter 'XXXXXX' but no such parameter 。
出现这个错误是由于 HAVE_OPENSSL这个没有define ,可以通过添加-D HAVE_OPENSSL=1 解决。
root@v238:~/httpd-2.2.26/modules/ssl# /usr/local/apache2/bin/apxs -i -c -a mod_ssl.c
/usr/local/apr-httpd//build-1/libtool --silent --mode=compile gcc -prefer-pic -DLINUX -D_REENTRANT -D_GNU_SOURCE -g -O2 -pthread -I/usr/local/apache2/include -I/usr/local/apr-httpd//include/apr-1 -I/usr/local/apr-util-httpd/include/apr-1 -c -o mod_ssl.lo mod_ssl.c && touch mod_ssl.slo
In file included from ssl_private.h:60:0,
from mod_ssl.c:27:
ssl_toolkit_compat.h:267:2: error: #error "Unrecognized SSL Toolkit!"
In file included from ssl_private.h:72:0,
from mod_ssl.c:27:
ssl_util_ssl.h:78:31: error: unknown type name 'SSL'
ssl_util_ssl.h:79:31: error: unknown type name 'SSL'
ssl_util_ssl.h:80:1: error: unknown type name 'X509'
ssl_private.h:637:14: error: declaration for parameter 'ssl_hook_Upgrade' but no such parameter
ssl_private.h:636:14: error: declaration for parameter 'ssl_hook_ReadReq' but no such parameter
ssl_private.h:635:14: error: declaration for parameter 'ssl_hook_Fixup' but no such parameter
ssl_private.h:634:14: error: declaration for parameter 'ssl_hook_Access' but no such parameter
ssl_private.h:633:14: error: declaration for parameter 'ssl_hook_UserCheck' but no such parameter
ssl_private.h:632:14: error: declaration for parameter 'ssl_hook_Auth' but no such parameter
ssl_private.h:629:14: error: declaration for parameter 'ssl_init_ModuleKill' but no such parameter
ssl_private.h:628:14: error: declaration for parameter 'ssl_init_Child' but no such parameter
mod_ssl.c:573:1: error: expected '{' at end of input
apxs:Error: Command failed with rc=65536
root@v238:~/httpd-2.2.26/modules/ssl# /usr/local/apache2/bin/apxs -i -c -a -D HAVE_OPENSSL=1 -I /usr/include/openssl mod_ssl.c
错误代码,undefined symbol: ssl_cmd_SSLMutex 。
apxs编译追加模块成功,但是apache启动失败。出现这个错误后,我把运行apxs时指定mod_ssl.c改成*.c 。和添加mod_deflate不一样,ssl中包含多个源代码文件。
root@v238:~/httpd-2.2.26/modules/ssl# /usr/local/apache2/bin/httpd -t
httpd: Syntax error on line 107 of /usr/local/apache2/conf/httpd.conf: Cannot load /usr/local/apache2/modules/mod_ssl.so into server: /usr/local/apache2/modules/mod_ssl.so: undefined symbol: ssl_cmd_SSLMutex
root@v238:~/httpd-2.2.26/modules/ssl#
root@v238:~/httpd-2.2.26/modules/ssl# /usr/local/apache2/bin/apxs -i -c -a -D HAVE_OPENSSL=1 -I /usr/include/openssl *.c
错误代码,undefined symbol: X509_INFO_free ,这个通常是由于静态连接了 openssl的库造成的(默认),解决办法是添加-lcrypto -lssl -ldl参数。
root@v238:~/httpd-2.2.26/modules/ssl# /usr/local/apache2/bin/httpd -t
httpd: Syntax error on line 107 of /usr/local/apache2/conf/httpd.conf: Cannot load /usr/local/apache2/modules/mod_ssl.so into server: /usr/local/apache2/modules/mod_ssl.so: undefined symbol: X509_INFO_free
root@v238:~/httpd-2.2.26/modules/ssl# /usr/local/apache2/bin/apxs -i -c -a -D HAVE_OPENSSL=1 -I /usr/include/openssl -lcrypto -lssl -ldl
到这里在已安装的apache中追加mod_ssl模块就完成了,不过还是建议在第一次编译apache的时候就添加ssl模块 。
以上是云栖社区小编为您精心准备的的内容,在云栖社区的博客、问答、公众号、人物、课程等栏目也有的相关内容,欢迎继续使用右上角搜索按钮进行搜索编译
apache 编译ssl、apache 动态编译ssl、apache 编译 mod ssl、apache添加ssl模块、apache安装ssl模块,以便于您获取更多的相关知识。
弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率
稳定可靠、可弹性伸缩的在线数据库服务,全球最受欢迎的开源数据库之一
6款热门基础云产品6个月免费体验;2款产品1年体验;1款产品2年体验
开发者常用软件,超百款实用软件一站式提供
云栖社区()为您免费提供相关信息,包括
的信息,还有apache 编译ssl、apache 动态编译ssl、apache 编译 mod ssl、apache添加ssl模块、apache安装ssl模块等
,所有相关内容均不代表云栖社区的意见!9740人阅读
(1) 下载openssl压缩包。在&&选择合适版本的压缩包,一般选择标记有“[LATEST]”的包,假设其link为&http://www.openssl.org/source/openssl-1.0.1c.tar.gz,用下面的下载:
# wget&http://www.openssl.org/source/openssl-1.0.1c.tar.gz&
(2) 解压压缩包,例如:解压到当前文件夹
# tar zcvf ./openssl-1.0.1c.tar.gz -C ./
解压完后会生成openssl文件夹,如&openssl-1.0.1c。
(3) 进入该文件夹,打开INSTALL 文件,可以看到安装的具体步骤,按照这些步骤一步步做下来,就完成了openssl的编译和安装:
# ./config
# make test
# make install
&&相关文章推荐
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:2703090次
积分:23562
积分:23562
排名:第275名
原创:158篇
转载:596篇
评论:201条
(1)(1)(2)(2)(1)(2)(1)(42)(17)(15)(15)(3)(6)(2)(13)(7)(14)(14)(18)(16)(32)(29)(14)(25)(22)(24)(10)(23)(27)(21)(21)(21)(28)(33)(51)(20)(29)(33)(26)(31)(2)(3)(10)(2)(3)(6)(11)(5)博客访问: 62312
博文数量: 11
博客积分: 1400
博客等级: 上尉
技术积分: 120
注册时间:
IT168企业级官微
微信号:IT168qiye
系统架构师大会
微信号:SACC2013
按照所述的编译方法:
gcc -Wall ssl-client.c -o client
这个时候会出现:
/tmp/ccMxO7rt.o: In function `ShowCerts':ssl-client.c:(.text+0xd): undefined reference to `SSL_get_peer_certificate' :ssl-client.c:(.text+0x31): undefined reference to `X509_get_subject_name' :ssl-client.c:(.text+0x49): undefined reference to `X509_NAME_oneline' :ssl-client.c:(.text+0x75): undefined reference to `X509_get_issuer_name' :ssl-client.c:(.text+0x8d): undefined reference to `X509_NAME_oneline' :ssl-client.c:(.text+0xb9): undefined reference to `X509_free' /tmp/ccMxO7rt.o: In function `main':ssl-client.c:(.text+0x11f): undefined reference to `SSL_library_init' :ssl-client.c:(.text+0x124): undefined reference to `OPENSSL_add_all_algorithms_noconf' :ssl-client.c:(.text+0x129): undefined reference to `SSL_load_error_strings' :ssl-client.c:(.text+0x12e): undefined reference to `SSLv23_client_method' :ssl-client.c:(.text+0x136): undefined reference to `SSL_CTX_new' :ssl-client.c:(.text+0x14c): undefined reference to `ERR_print_errors_fp' :ssl-client.c:(.text+0x280): undefined reference to `SSL_new' :ssl-client.c:(.text+0x295): undefined reference to `SSL_set_fd' :ssl-client.c:(.text+0x2a0): undefined reference to `SSL_connect' :ssl-client.c:(.text+0x2b2): undefined reference to `ERR_print_errors_fp' :ssl-client.c:(.text+0x2bf): undefined reference to `SSL_get_current_cipher' :ssl-client.c:(.text+0x2c7): undefined reference to `SSL_CIPHER_get_name' :ssl-client.c:(.text+0x320): undefined reference to `SSL_read' :ssl-client.c:(.text+0x3d2): undefined reference to `SSL_write' :ssl-client.c:(.text+0x46b): undefined reference to `SSL_shutdown' :ssl-client.c:(.text+0x476): undefined reference to `SSL_free' :ssl-client.c:(.text+0x48c): undefined reference to `SSL_CTX_free' collect2: ld returned 1 exit status
如果碰到此问题,请如下进行编译:
gcc -Wall -lssl ssl-client.c -o client
链接静态库ssl,crypto,编译就不会错了.
参考:http://www.cis.nctu.edu.tw/chinese/doc/ciscc/faq/sun/sun05_07.html
阅读(14300) | 评论(0) | 转发(0) |
相关热门文章
给主人留下些什么吧!~~
请登录后评论。

我要回帖

更多关于 linux交叉编译openssl 的文章

 

随机推荐