【问题标题】:Apache won't start in CentOS 7 due to missing SSLCertificateFile由于缺少 SSLCertificateFile,Apache 无法在 CentOS 7 中启动
【发布时间】:2020-07-09 01:39:59
【问题描述】:

安装 Web 服务器后 Apache 不启动。 (CentOS 7)

● httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Sat 2020-03-28 12:18:22 MSK; 16ms ago
Docs: man:httpd.service(8)
Process: 30144 ExecStart=/usr/sbin/httpd $OPTIONS -DFOREGROUND (code=exited, status=1/FAILURE)
Main PID: 30144 (code=exited, status=1/FAILURE)
Status: "Reading configuration..."

Mar 28 12:18:22 box-40395.localdomain systemd[1]: Starting The Apache HTTP Server...
Mar 28 12:18:22 box-40395.localdomain httpd[30144]: AH00526: Syntax error on line 103 of /etc/httpd/conf.d/ssl.conf:
Mar 28 12:18:22 box-40395.localdomain httpd[30144]: SSLCertificateFile: file '/etc/pki/tls/certs/localhost.crt' does not exist or is empty
Mar 28 12:18:22 box-40395.localdomain systemd[1]: httpd.service: main process exited, code=exited, status=1/FAILURE
Mar 28 12:18:22 box-40395.localdomain systemd[1]: Failed to start The Apache HTTP Server.
Mar 28 12:18:22 box-40395.localdomain systemd[1]: Unit httpd.service entered failed state.
Mar 28 12:18:22 box-40395.localdomain systemd[1]: httpd.service failed.

【问题讨论】:

    标签: apache centos


    【解决方案1】:

    您可以尝试创建一个假证书。

    在 centos 中有一个方便的脚本可能会有所帮助

    $ cd /etc/pki/tls/certs
    $ sudo ./make-dummy-cert localhost.crt
    

    此脚本生成自签名证书和证书的私钥。

    因此 /etc/httpd/conf.d/ssl.conf 中的 SSLCertificateKeyFile 可以被注释掉

    SLCertificateFile /etc/pki/tls/certs/localhost.crt
    # SSLCertificateKeyFile /etc/pki/tls/private/localhost.key
    

    否则服务将无法启动

    【讨论】:

      【解决方案2】:

      错误信息很清楚:

      SSLCertificateFile: 文件/etc/pki/tls/certs/localhost.crt 不存在或为空

      删除此无效配置或添加缺失/修复现有证书文件。无论哪种方式都必须在 Apache 启动之前修复配置。

      获取 SSL 证书超出了 StackOverflow 的范围。网上有很多资源,你也可以试试ServerFault...

      完成后,只需sudo systemctl start httpd 即可启动 Apache。

      【讨论】:

        猜你喜欢
        • 2016-11-12
        • 2014-03-14
        • 1970-01-01
        • 2019-01-27
        • 2018-10-24
        • 2015-03-19
        • 1970-01-01
        • 2017-10-15
        • 2017-06-23
        相关资源
        最近更新 更多