Search code examples
serverlampp

Unable to configure SSL to httpd-vhosts.conf


I'm using the ubuntu 16.04 server & lampp server and I get this error XAMPP: Your /etc/hosts is not okay. I will fix it. when I uncomment this line #SSLEngine on

So far it is running fine in port 80 I want to add SSL to it

Please help me out.

My httpd-vhosts.conf file

<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>

My /etc/hosts file

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

The error when I uncomment #SSLEngine on

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

Solution

  • The reason is I have provided the privkey.pem in SSLCertificateFile & cert.pem in SSLCertificateKeyFile

    #SSLCertificateFile /etc/letsencrypt/live/example.com/privkey.pem
    #SSLCertificateKeyFile /etc/letsencrypt/live/example.com/cert.pem
    

    After changing to this it worked fine & no need of SSLCertificateChainFile

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