在 Apache 上安装 SSL - openssl.cnf 中的语法错误

Installing SSL on Apache - Syntax Error in openssl.cnf

我正在尝试学习如何在 apache 2.4 网络服务器(Windows Server 2012)上启动 ssl 和 运行。我有 Web 服务器和 PHP 启动并且 运行 在没有 SSL 的情况下完全正常。

LoadModule ssl_module modules/mod_ssl.so
Include C:/Apache24/conf/openssl.cnf

SSLCertificateFile "c:/Apache24/conf/server.crt" SSLCertificateKeyFile "c:/Apache24/conf/server.key" DocumentRoot "c:/Apache24/htdocs"

Variable Name: OPENSSL_CONF Variable Value: C:\Apache24\conf\openssl.cnf

由于以下错误,我遇到了 apache 无法启动的问题。

运行 powershell 中的 httpd -t 给出结果:

: Syntax error on line 8 of C:/Apache24/conf/openssl.cnf:
Invalid command 'HOME', perhaps misspelled or defined by a module not included in the server configuration

以下是 openssl.cnf 的第 6 行到第 9 行(我没有修改此文件。)

# This definition stops the following lines choking if HOME isn't
# defined.
HOME            = .
RANDFILE        = $ENV::HOME/.rnd

感谢任何帮助。 谢谢!

您基本上是在尝试在 httpd 配置中包含第三方配置文件,这永远不会产生好的结果,因为 Apache httpd 永远不会识别其中的内容。 删除包含.

如果您想添加系统变量,您可以使用 mod_env 模块中的 PassEnv 指令。

要启动 SSL,运行 您只需要一个像这样的 SSL 虚拟主机:

在您的服务器配置中:

LoadModule ssl_module modules/mod_ssl.so
<IfModule mod_ssl.c>
        Listen 443
        LoadModule socache_shmcb_module modules/mod_socache_shmcb.so
        SSLProtocol all -SSLv3
        SSLCipherSuite ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256
        SSLHonorCipherOrder     on
        SSLCompression          off
        SSLSessionTickets       off
        SSLRandomSeed startup file:/dev/urandom 2048 # perhaps this need to be adapted for windows
        SSLRandomSeed connect file:/dev/urandom 2048 # same with this
        SSLSessionCache shmcb:/path/to/logs/ssl_gcache_data(512000)
</IfModule>

和虚拟主机:

<Virtualhost *:443>
ServerName myssllvh.example.com
DocumentRoot /filesystem/path/to/docroot
CustomLog /path/to/logs/mysslvh.log combined
ErrorLog /path/to/logs/mysslvh-error.log

SSLEngine on
SSLCertificateFile /path/to/certs/mysslvh.crt
SSLCertificateKeyFile /path/to/certs/mysslvh.key

# Other stuff here
</VirtualHost>