【问题标题】:How to determine if OpenSSL and mod_ssl are installed on Apache2如何确定 Apache2 上是否安装了 OpenSSL 和 mod_ssl
【发布时间】:2009-09-02 12:56:35
【问题描述】:

有人知道确定OpenSSL和mod_ssl是否安装在Apache2上的命令吗?

【问题讨论】:

  • 你想达到什么目的?
  • 我正在尝试安装 ssl 证书。第一步说我需要确保我安装了 OpenSSL 和 mod_ssl。我以为我有,因为我启用了 ssl 模块并安装了 ssl。但是,当我运行第一个命令时: openssl genrsa –des3 1024 –out www.mydomain.com.key 我得到了看起来像帮助信息的内容。所以我决定在查看之前尝试确定是否先安装了 OpenSSl 和 mod_ssl命令。希望这能解释我想要做什么!谢谢,菲奥娜

标签: ssl apache2


【解决方案1】:

使用以下命令。

$ openssl version
OpenSSL 1.0.1e-fips 11 Feb 2013 (or similar output)

对于 RHEL/CentOS/Fedora:

$ httpd -t -D DUMP_MODULES | grep ssl
ssl_module (shared)

适用于 Ubuntu/Debian

$ apache2 -t -D DUMP_MODULES | grep ssl
ssl_module (shared)

对于 SUSE

$ httpd2 -t -D DUMP_MODULES 2>&1 | grep ssl
ssl_module (shared)

【讨论】:

    【解决方案2】:

    通常,当你编译你的 apache2 服务器(或通过包工具安装它)时,你可以通过点击这个命令来检查任何可用的指令:

    ~# $(which httpd) -L | grep SSL # on RHEL/CentOS/Fedora
    ~# $(which apache2) -L | grep SSL # on Ubuntu/Debian
    ~# $(which httpd2) -L | grep SSL # on SUSE
    

    如果您没有看到任何 SSL* 指令,则表示您没有编译带有 mod_ssl 的 apache2。

    【讨论】:

    • 这应该是公认的答案。没有人在这个问题中谈论 PHP。
    【解决方案3】:

    幸运的是,大多数 Linux 版本都有“开箱即用”的 OpenSSL。

    验证安装:

    openssl version
    回复:
    OpenSSL 1.0.1t 3 May 2016

    注意:版本 OpenSSL 1.0.1 至 1.0.1f(含)
    容易受到 OpenSSL Heartbleed 错误的影响。
    1.0.1g 及更高版本已修复。

    更多安装信息:

    Ubuntu/Debian
    dpkg -l | grep -i openssl
    回复:
    ii libcrypt-openssl-random-perl 0.04-2+b1 amd64 module to access the OpenSSL pseudo-random number generator
    ii libcurl3:amd64 7.38.0-4+deb8u5 amd64 easy-to-use client-side URL transfer library (OpenSSL flavour)
    ii libgnutls-openssl27:amd64 3.3.8-6+deb8u4 amd64 GNU TLS library - OpenSSL wrapper
    ii openssl 1.0.1t-1+deb8u6 amd64 Secure Sockets Layer toolkit - cryptographic utility
    ii python-ndg-httpsclient 0.3.2-1 all enhanced HTTPS support for httplib and urllib2 using PyOpenSSL
    ii python-openssl 0.14-1 all Python 2 wrapper around the OpenSSL library
    ii ssl-cert 1.0.35 all simple debconf wrapper for OpenSSL

    是的,OpenSSL 已安装!

    如果您没有 OpenSSL,请尝试安装它:

    Debian/Ubuntu:
    sudo apt-get install openssl

    RedHat/CentOS:
    yum install openssl

    【讨论】:

      【解决方案4】:

      默认的 Apache 安装配置为在 Server 标题行上发送此信息。您可以使用 curl 命令查看任何服务器的此内容。

      $ curl --head http://localhost/
      HTTP/1.1 200 OK
      Date: Fri, 04 Sep 2009 08:14:03 GMT
      Server: Apache/2.2.8 (Unix) mod_ssl/2.2.8 OpenSSL/0.9.8a DAV/2 PHP/5.2.6 SVN/1.5.4 proxy_html/3.0.0
      

      【讨论】:

      • 这在 ServerSignature 和 ServerTokens 设置为在 Apache 中显示有限数据时没有帮助。
      • 在我的情况下,没有出现 openssl,尽管我的正在运行。我们在谈论什么版本的操作系统?
      【解决方案5】:

      在 www 文件夹中创建一个包含以下代码的 test.php 文件:

      <?php echo phpinfo();?>
      

      当您在浏览器中导航到该页面/URL 时。如果您启用了 openssl,您将看到类似的内容:

      【讨论】:

        【解决方案6】:

        如果您的服务器上安装了 PHP,您可以使用“extension_loaded”函数在运行时检查它。就像这样:

        <?php
        if (!extension_loaded('openssl')) {
            // no openssl extension loaded.
        }
        ?>
        

        【讨论】:

        • 这是最干净的解决方案,例如我正在为我的安装程序构建系统要求页面。
        • 当我们想让我们的域自动从http://重定向到https://时,这个解决方案最适合用在PHP代码中,谢谢你节省了我的薪水!
        【解决方案7】:

        如果您的服务器上安装了 PHP,您可以创建一个 php 文件,我们将其命名为 phpinfo.php 并添加此&lt;?php echo phpinfo();?&gt;,然后在浏览器中打开该文件,这将显示有关您的系统环境的信息,以快速查找有关您的 Apache 加载模块的信息,在结果页面上找到“加载模块”。

        【讨论】:

        • 其实你不需要'echo',这个函数提供了它自己的输出。
        【解决方案8】:

        使用 Apache 2,您可以通过运行以下命令查看 HTTP 守护程序当前加载了哪些模块:

        apache2ctl -M
        

        -M 选项实际上只是传递给 httpd 的参数。

        apache2ctl 是 Apache 超文本传输​​协议的前端 (HTTP) 服务器。这是 旨在帮助管理员控制 Apache apache2 守护进程的功能。

           NOTE: The default Debian configuration requires the environment variables APACHE_RUN_USER,
           APACHE_RUN_GROUP, and APACHE_PID_FILE to be set in /etc/apache2/envvars.
        
           The apache2ctl script returns a 0 exit value on success, and >0 if an error  occurs.   For
           more details, view the comments in the script.
        

        【讨论】:

        • 需要使用sudo 运行此命令,因为当我这样做时,它会返回SSLCertificateFile: file /path/to/my/certificate/fullchain.pem does not exist or is empty 的错误。这是正常情况还是我的 SSL 配置不正确?
        【解决方案9】:

        确定opensslssl_module

        # rpm -qa | grep openssl
        openssl-libs-1.0.1e-42.el7.9.x86_64
        openssl-1.0.1e-42.el7.9.x86_64
        openssl098e-0.9.8e-29.el7.centos.2.x86_64
        openssl-devel-1.0.1e-42.el7.9.x86_64
        

        mod_ssl

        # httpd -M | grep ssl
        

        # rpm -qa | grep ssl
        

        【讨论】:

          【解决方案10】:

          您应该安装这个 Apache 模组http://httpd.apache.org/docs/2.0/mod/mod_info.html,它基本上可以让您了解您正在使用的模组和 Apache 设置。 我在我的 Apache 上启用了此功能,它为我的网站提供了此信息,

          服务器版本:Apache/2.2.3 (Debian) mod_jk/1.2.18 PHP/5.2.0-8+etch13 mod_ssl/2.2.3 OpenSSL/0.9.8c mod_perl/2.0.2 Perl/v5.8.8

          【讨论】:

            【解决方案11】:

            在php命令中验证谎言

             $php -i | grep openssl
            

            【讨论】:

              【解决方案12】:

              只需查看您的 Apache 日志目录中的 ssl_engine.log,您应该会在其中找到如下内容:

              [ssl:info] [pid 5963:tid 139718276048640] AH01876: mod_ssl/2.4.9 compiled against Server: Apache/2.4.9, Library: OpenSSL/1.0.1h
              

              【讨论】:

                【解决方案13】:

                找到ssl version

                1. 在命令提示符下转到 Apache bin 文件夹
                2. 输入这些命令“openssl 版本”

                【讨论】:

                  【解决方案14】:

                  如果您只是在终端中运行 openssl,它应该会显示 openSSL shell。我知道我没有mode_ssl 的第一个线索是在我的虚拟主机文件中添加SSLEngine on 后出现以下错误:

                  Invalid command 'SSLEngine', perhaps misspelled or defined by a module not included in the server configuration
                  

                  在 centos 中,我只需通过 yum install mod_ssl 安装它

                  【讨论】:

                    【解决方案15】:

                    在 httpd.conf 中启用 mod_ssl 并重启 apache。您将在 error.log 中看到 openssl 信息,如下所示

                    [Fri Mar 23 15:13:38.448268 2018] [mpm_worker:notice] [pid 8891:tid 1] AH00292: Apache/2.4.29 (Unix) OpenSSL/1.0.2n configured -- resuming normal operations
                    [Fri Mar 23 15:13:38.448502 2018] [core:notice] [pid 8891:tid 1] AH00094: Command line: '/opt/apps/apache64/2.4.29/bin/httpd'

                    【讨论】:

                      【解决方案16】:

                      就我而言,这是我获取信息的方式:

                      • 找到 apache 日志所在的位置,然后去那里,在我的例子中:

                        cd /var/log/apache2

                      • 在哪个日志中可以找到openssl信息:

                        grep -i apache.*openssl *_log

                        e.g. error_log ...

                      • 要获取最新信息,请重启 apache,例如

                        rcapache2 restart # or service apache2 restart

                      • 检查日志中的最后一个条目,例如

                        /var/log/apache2 # tail error_log

                        [Thu Jun 09 07:42:24 2016] [notice] Apache/... (Linux/...) mod_ssl/2.2.22 OpenSSL/1.0.1t ...

                      【讨论】:

                        猜你喜欢
                        • 2016-11-28
                        • 1970-01-01
                        • 1970-01-01
                        • 2013-11-02
                        • 1970-01-01
                        • 1970-01-01
                        • 2013-02-20
                        • 2014-10-21
                        • 2018-11-01
                        相关资源
                        最近更新 更多