« Humane Resource 相关英语词汇汇总 | 首 页 | Boot Linux: 关于启动 Linux 的各种配置纪录 »

2005 年 06 月 07 日

OpenSSL 升级中的一些问题

| 分类: 服务器技术 Server Tech. |

Problem building Apache with OpenSSL

  • 目的: 升级 OpenSSL (tarball package) 到 0.9.7g
  • 问题: 原本服务器上安装有 rpm 的 0.9.6b ,
    # rpm -qa | grep openssl
    openssl-0.9.6b-35.7
    openssl-devel-0.9.6b-35.7
    这使得重新编译 apache 时出现以下错误:
    error while loading shared libraries: libssl.so.0.9.7: cannot open shared object file: No such file or directory openssl

  • 解说: 主要问题还是在路径和 link 上。
    # ldd -v /usr/bin/openssl
    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

    由于 OpenSSL package 的 lib 路径已经变成 /usr/local/ssl/lib ,所以需要将这个路径加入到服务器的 lib 路径中去,然后让 apache 的 configure 文件进行搜索。
  • 解决方法: 方法有很多,看大家喜欢哪个了。

    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
  • OpenSSL 的 config 语句:
    ./config --prefix=/usr/local/ssl shared zlib threads
    注意: defalut path 是 /usr/local/ssl ,在 config 中不必要写明 --prefix=/usr/local/ssl ;同时 --openssldir 不需要设置。

  • Apache 2.0.54 的 configure 语句:
    ./configure --prefix=/usr/local/apache2 --enable-module=so --enable-module=rewrite --enable-module=speling --enable-ssl --with-ssl=/usr/local/ssl
  • 参考: apache 在编译中有一段话,说的内容和我们现在做的事情很像,可以参考一下:
    PATH="$PATH:/sbin" ldconfig -n /usr/local/apache2/lib
    ----------------------------------------------------------------------
    Libraries have been installed in:
    /usr/local/apache2/lib

    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.
    ----------------------------------------------------------------------

  • (END)

    引用

    引用本文的 URL:
    http://weblog.kreny.com/cgi-bin/mt/mt-tb.cgi/231.

    发表评论

    (如果您还为在此成功留言,也许是因为需要管理员逐一审核留言内容后放可看到您的评论。请稍后并感谢您的耐心等待。)

    阅览更多文章请访问 首页过去的存档