In this article We will generate SSL and then enable HTTPS on Apache with Ubuntu 20.04.
#1 Generate SSL Certificate
Step 1. Install acme.sh and then reconnect to ssh
wget -O - https://get.acme.sh | sh
exit
Step 2. Create a folder where SSL files will be stored
mkdir /etc/letsencrypt/live/
Step 3. Register acme account and upgrade
acme.sh --upgrade
acme.sh --register-account -m stefan@pcx3.com
Step 4. Run the following command to generate SSL, but make sure to change the following first:
DOMAIN | your domain name |
/var/www/html/public/ | path to your website directory |
/root/.acme.sh/acme.sh --issue -d DOMAIN -d www.DOMAIN --cert-file /etc/letsencrypt/live/DOMAIN/cert.pem --key-file /etc/letsencrypt/live/DOMAIN/privkey.pem --fullchain-file /etc/letsencrypt/live/DOMAIN/fullchain.pem -w /var/www/html/public/ --force --debug
The SSL will be output to the screen

and stored in the specified location: /etc/letsencrypt/live/DOMAIN/

#2 Change VirtualHost file
nano /etc/apache2/sites-available/default-ssl.conf
add the path to the fullchain and privkey files:

#3 Configure Apache modules
Enable the mod_ssl and mod_headers modules, then check for syntax errors in Apache configuration files and finally restart Apache.
a2enmod ssl
a2enmod headers
a2ensite default-ssl
apache2ctl configtest
service apache2 restart
That’s it, now check the secure connection: https://mydomain.com