Problem building Apache with OpenSSL
# rpm -qa | grep openssl这使得重新编译 apache 时出现以下错误:
openssl-0.9.6b-35.7
openssl-devel-0.9.6b-35.7
error while loading shared libraries: libssl.so.0.9.7: cannot open shared object file: No such file or directory openssl
# ldd -v /usr/bin/openssl由于 OpenSSL package 的 lib 路径已经变成 /usr/local/ssl/lib ,所以需要将这个路径加入到服务器的 lib 路径中去,然后让 apache 的 configure 文件进行搜索。
libdl.so.2 => /lib/libdl.so.2 (0x4001c000)
libc.so.6 => /lib/libc.so.6 (0x40020000)
/lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)Version information:
/usr/bin/openssl:
libdl.so.2 (GLIBC_2.1) => /lib/libdl.so.2
libdl.so.2 (GLIBC_2.0) => /lib/libdl.so.2
libc.so.6 (GLIBC_2.1) => /lib/libc.so.6
libc.so.6 (GLIBC_2.2) => /lib/libc.so.6
libc.so.6 (GLIBC_2.0) => /lib/libc.so.6
/lib/libdl.so.2:
ld-linux.so.2 (GLIBC_PRIVATE) => /lib/ld-linux.so.2
libc.so.6 (GLIBC_2.3) => /lib/libc.so.6
libc.so.6 (GLIBC_2.1.3) => /lib/libc.so.6
libc.so.6 (GLIBC_2.1) => /lib/libc.so.6
libc.so.6 (GLIBC_PRIVATE) => /lib/libc.so.6
libc.so.6 (GLIBC_2.0) => /lib/libc.so.6
/lib/libc.so.6:
ld-linux.so.2 (GLIBC_2.1) => /lib/ld-linux.so.2
ld-linux.so.2 (GLIBC_2.0) => /lib/ld-linux.so.2
ld-linux.so.2 (GLIBC_PRIVATE) => /lib/ld-linux.so.2
1) 运行一下命令:
ldconfig /usr/local/ssl/lib
2) 将 /usr/local/ssl/lib 路径写入 /etc/ld.so.conf
include ld.so.conf.d/*.conf
/usr/kerberos/lib
/usr/X11R6/lib
/usr/local/lib
/usr/local/ssl/lib <--追加
3) 将现有的 libssl.so.x link 到 libssl.so.0.9.7(以下只是一个例子,根据每个主机的状态不同,运行的命令是不同的)
$ cd /lib (路径不同)
$ ln -s libcrypto.so.0.9.7 libcrypto.so.6
$ ln -s libssl.so.0.9.7 libssl.so.6
4) 在编译 apache 之前,在 shell 里面定义以下变量
$ LD_LIBRARY_PATH=/usr/local/ssl/lib
$ export LD_LIBRARY_PATH
./config --prefix=/usr/local/ssl shared zlib threads注意: defalut path 是 /usr/local/ssl ,在 config 中不必要写明 --prefix=/usr/local/ssl ;同时 --openssldir 不需要设置。
./configure --prefix=/usr/local/apache2 --enable-module=so --enable-module=rewrite --enable-module=speling --enable-ssl --with-ssl=/usr/local/ssl
PATH="$PATH:/sbin" ldconfig -n /usr/local/apache2/lib
----------------------------------------------------------------------
Libraries have been installed in:
/usr/local/apache2/libIf 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.
----------------------------------------------------------------------