Apache不会在CentOS 7中启动,因为缺少SSLCertificateFile

bvjxkvbb  于 2023-06-22  发布在  Apache
关注(0)|答案(3)|浏览(209)

安装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.
11dmarpk

11dmarpk1#

您可以尝试创建一个假证书。
在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

否则服务将无法启动

mbzjlibv

mbzjlibv2#

3月28日12:18:22 box-40395.localdomain httpd[30144]:SSL证书文件:您访问的页面不存在或已被删除提示信息
错误消息指出缺少SSLCertificateFile。您可以使用以下命令生成这些文件来解决此问题。

sudo openssl req -newkey rsa:2048 -nodes -keyout /etc/pki/tls/private/localhost.key -x509 -days 365 -out /etc/pki/tls/certs/localhost.crt
pdsfdshx

pdsfdshx3#

错误信息非常明确:
SSL证书文件:您访问的页面不存在或已被删除提示信息
删除此无效配置或添加缺少的/修复现有证书文件。无论哪种方式都必须在Apache启动之前修复配置。
获取SSL证书超出了StackOverflow的范围。网上有很多资源,你也可以试试ServerFault...
完成后,只需执行sudo systemctl start httpd即可启动Apache。

相关问题