如何在没有虚拟主机的情况下将 SSL/443 添加到 Apache 服务器?

Don*_*mmy 6 ssl httpd httpd.conf apache-2.2 apache-2.4

我在 CentOS 上设置了一个 apache 服务器。我正在尝试添加 SSL。我能够创建证书和密钥,然后更新/etc/httpd/conf.d/ssl.conf为具有以下配置:

/etc/httpd/conf.d/ssl.conf

#Where I put my cert
SSLCertificateFile /etc/pki/tls/certs/ca.crt

#where I put my key
SSLCertificateKeyFile /etc/pki/tls/private/ca.key
Run Code Online (Sandbox Code Playgroud)

然后我更新了/etc/httpd/conf/httpd.conf

/etc/httpd/conf/httpd.conf

Listen 443
SSLEngine on
SSLCertificateFile /etc/pki/tls/certs/ca.crt
SSLCertificateKeyFile /etc/pki/tls/private/ca.key
Run Code Online (Sandbox Code Playgroud)

然后我跑了service httpd restart,我得到了错误:

Stopping httpd:          [OK]
Starting httpd:          (98)Address already in use: make_sock: could not bind to address [::]:443
                         [OK]
Run Code Online (Sandbox Code Playgroud)

我需要做什么才能启用 SSL?

Don*_*mmy 7

默认情况下,在 CentOS 中,有一个 Apache/httpd 使用的文件位于/etc/httpd/conf.d/ssl.conf. 该文件作为配置被 Apache 与“httpd.conf”文件一起读入,其中的任何内容都优先于httpd.conf.

该文件(再次默认)包含一个Listen 443指令。您不能两次调用该指令(因为它会说它已经绑定到该端口),因此导致了冲突。删除后,它可以工作。