无法配置 SSL 到 httpd-vhosts.conf

Unable to configure SSL to httpd-vhosts.conf

我正在使用 ubuntu 16.04 服务器和 lampp 服务器,当我取消注释此行 #SSLEngine on

时出现此错误 XAMPP: Your /etc/hosts is not okay. I will fix it.

到目前为止 运行 端口 80 没问题我想给它添加 SSL

请帮帮我。

我的httpd-vhosts.conf文件

<VirtualHost 127.0.0.4:443>
  DocumentRoot "/opt/lampp/htdocs/example.com/public"
  ServerName example.com
  DirectoryIndex index.php

  #SSLEngine on
  #SSLCertificateFile /etc/letsencrypt/live/example.com/privkey.pem
  #SSLCertificateKeyFile /etc/letsencrypt/live/example.com/cert.pem
  #SSLCertificateChainFile /etc/letsencrypt/live/example.com/chain.pem
  <Directory "/opt/lampp/htdocs/example.com/public">
        Options All
        AllowOverride All
        Require all granted
  </Directory>
</VirtualHost>

我的/etc/hosts文件

127.0.0.1       localhost
127.0.0.4       example.com

# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts

取消注释时的错误#SSLEngine on

XAMPP:  Starting diagnose... 
XAMPP: Your /etc/hosts is not okay. I will fix it.
XAMPP:  Next try...

原因是我在SSLCertificateFile中提供了privkey.pem,在SSLCertificateKeyFile

中提供了cert.pem
#SSLCertificateFile /etc/letsencrypt/live/example.com/privkey.pem
#SSLCertificateKeyFile /etc/letsencrypt/live/example.com/cert.pem

改成这个后效果很好,不需要 SSLCertificateChainFile

SSLCertificateFile /etc/letsencrypt/live/example.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem