apache - 如何使 mod_ssl 指向不同的 openssl 目录而不是 apache 中的默认目录?

标签 apache openssl centos yum mod-ssl

之所以提出这个问题,是因为原始的 openssl 版本没有通过漏洞扫描,因此我需要在 apache centos 7 上升级 openssl 包,并且我正在使用 httpd。我花了一些时间后有一些观察

  • 默认的 openssl 版本是 OpenSSL 1.0.2k-fips,这是 mod_ssl 的默认 openssl 版本,它又是 httpd 2.4.6-97.el7.centos.5 包的依赖,所以当我 yum install httpd 时, mod_ssl 自动指向该 openssl 版本
  • 我遵循 https://gist.github.com/fernandoaleman/5459173e24d59b45ae2cfc618e20fe06 中的指南
    ,我安装的是3.0.0版本,而不是1.1.1版本,其他命令和上面提到的指南一样,我通过运行openssl version检查了升级后的openssl版本,输出是正确的,但是当我向服务器发送请求时,响应头仍然显示原始版本:Server: Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips mod_wsgi/4.5.18 Python/3.6
  • 这是我 ldd mod_ssl.so 时的输出在 /usr/lib64/httpd/modules folder :
  •         linux-vdso.so.1 =>  (0x00007ffd44ddd000)
            libssl.so.10 => /lib64/libssl.so.10 (0x00007fe07f09c000)
            libcrypto.so.10 => /lib64/libcrypto.so.10 (0x00007fe07ec39000)
            libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fe07ea1d000)
            libdl.so.2 => /lib64/libdl.so.2 (0x00007fe07e819000)
            libc.so.6 => /lib64/libc.so.6 (0x00007fe07e44b000)
            libgssapi_krb5.so.2 => /lib64/libgssapi_krb5.so.2 (0x00007fe07e1fe000)
            libkrb5.so.3 => /lib64/libkrb5.so.3 (0x00007fe07df15000)
            libcom_err.so.2 => /lib64/libcom_err.so.2 (0x00007fe07dd11000)
            libk5crypto.so.3 => /lib64/libk5crypto.so.3 (0x00007fe07dade000)
            libz.so.1 => /lib64/libz.so.1 (0x00007fe07d8c8000)
            /lib64/ld-linux-x86-64.so.2 (0x00007fe07f545000)
            libkrb5support.so.0 => /lib64/libkrb5support.so.0 (0x00007fe07d6b8000)
            libkeyutils.so.1 => /lib64/libkeyutils.so.1 (0x00007fe07d4b4000)
            libresolv.so.2 => /lib64/libresolv.so.2 (0x00007fe07d29a000)
            libselinux.so.1 => /lib64/libselinux.so.1 (0x00007fe07d073000)
            libpcre.so.1 => /lib64/libpcre.so.1 (0x00007fe07ce11000)
    
    我知道这是一个依赖问题,mod_ssl 没有指向新安装的openssl 3.0.0,那么有没有办法让mod_ssl 指向新的openssl 版本?或者我可以将 openssl 3.0.0 安装到 mod_ssl 指向的默认目录? (我不想手动安装httpd,因为我不想破坏依赖关系)我是服务器的初学者,如果你们能帮我一把,谢谢

    最佳答案

    假设您已经从官方 centos 存储库安装了 apache + mod_ssl + openssl,您可以执行以下操作:
    对于 OpenSSL:

    cd /opt/
    wget https://ftp.openssl.org/source/openssl-1.1.1k.tar.gz
    tar zxvf openssl-1.1.1k.tar.gz
    cd /opt/openssl-1.1.1k
    ./config -fpic shared
    make -j4
    make install
    
    对于 Apache(您可能会使用较新的版本,我只是使用了与官方存储库中相同的版本):
    cd /opt
    wget https://dlcdn.apache.org/httpd/httpd-2.4.53.tar.gz
    tar zxvf httpd-2.4.53.tar.gz
    cd /opt/httpd-2.4.53
    ./configure --build=x86_64-redhat-linux-gnu --host=x86_64-redhat-linux-gnu --program-prefix= --disable-dependency-tracking --prefix=/usr --exec-prefix=/usr --bindir=/usr/bin --sbindir=/usr/sbin --sysconfdir=/etc --datadir=/usr/sh--includedir=/usr/include --libdir=/usr/lib64 --libexecdir=/usr/libexec --localstatedir=/var --sharedstatedir=/var/lib --mandir=/usr/share/man --infodir=/usr/share/info --prefix=/etc/httpd --exec-prefix=/usr --bindir=/usr/--sbindir=/usr/sbin --mandir=/usr/share/man --libdir=/usr/lib64 --sysconfdir=/etc/httpd/conf --includedir=/usr/include/httpd --libexecdir=/usr/lib64/httpd/modules --datadir=/usr/share/httpd --enable-layout=Fed--with-installbuilddir=/usr/lib64/httpd/build --enable-mpms-shared=all --with-apr=/usr --with-apr-util=/usr --enable-suexec --with-suexec --enable-suexec-capabilities --with-suexec-caller=apache --with-suexec-oot=/var/--without-suexec-logfile --with-suexec-syslog --with-suexec-bin=/usr/sbin/suexec --with-suexec-uidmin=500 --with-suexec-gidmin=100 --enable-pie --with-pcre --enable-mods-shared=all --enable-ssl --with-ssl --die-distca--enable-proxy --enable-cache --enable-disk-cache --enable-ldap --enable-authnz-ldap --enable-cgid --enable-cgi --enable-authn-anon --enable-authn-alias --disable-imag
    
    make -j4
    make install
    
    systemctl restart httpd
    
    基本上它会从源代码编译 Apache,mod_ssl 以及它会将默认文件替换为您刚刚编译的文件。
    在我的 centos7 linux 机器上进行了测试:
    [Tue May 17 12:13:19.777713 2022] [mpm_prefork:notice] [pid 3179] AH00163: Apache/2.4.53 (Unix) OpenSSL/1.1.1k configured -- resuming normal operations
    

    关于apache - 如何使 mod_ssl 指向不同的 openssl 目录而不是 apache 中的默认目录?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72258129/

    相关文章:

    apache - 在 Unix 网络服务器上运行的 Ubuntu 编译程序

    apache - 如何使用 Spring Boot 提供位于 Dropbox 文件夹中的静态内容?

    mysql:/usr/local/lib/libssl.so.1.1: version `OPENSSL_1_1_1' not found (mysql 需要)

    openssl - "BEGIN RSA PRIVATE KEY"和 "BEGIN PRIVATE KEY"之间的区别

    php - CentOS:在 PHP 安装中启用 GD 支持

    sockets - 在 CentOS 上的 Hadoop 数据节点上打开套接字连接

    linux - 签署虚拟盒模块(vboxdrv、vboxnetflt、vboxnetadp、vboxpci)Centos 8

    django - 强制 django_compressor 重新编译 css/less 文件

    linux - 如何在使用 ANT 的 <exec> 启动程序后关闭终端窗口?

    c# - C和C#之间的RSA加密