Ubuntu Apache2 web server manual HTTPS certificate with LetsEncrypt

1. Enable both HTTP and HTTPS website configuration on apache2.

sudo a2ensite 000-default
sudo a2ensite default-ssl

2. Enable SSL mode in apache2.

sudo a2enmod ssl

3. Configure redirect from HTTP to HTTPS under /etc/apache2/sites-available/000-default.conf.

<VirtualHost *:80>
   ServerName www.yourdomain.com
   Redirect / https://www.yourdomain.com
</VirtualHost>

4. Configure /etc/apache2/sites-available/default-ssl.conf to use your LetsEncrypt's certificate manually.

<VirtualHost *:443>
   SSLCertificateChainFile /etc/letsencrypt/live/www.yourdomain.com/chain.pem
   SSLCertificateFile /etc/letsencrypt/live/www.yourdomain.com/cert.pem
   SSLCertificateKeyFile /etc/letsencrypt/live/www.yourdomain.com/privkey.pem
</VirtualHost>

5. Restart apache2 service.

sudo systemctl restart apache2

Comments