Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the copy-the-code domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /var/www/html/pcx3.com/wp-includes/functions.php on line 6121
How to generate SSL and enable HTTPS protocol with Apache 2 on Ubuntu 21 - PC✗3
How to generate SSL and enable HTTPS protocol with Apache 2 on Ubuntu 21

How to generate SSL and enable HTTPS protocol with Apache 2 on Ubuntu 21

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:

DOMAINyour 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

notepad GklzPdgpaD - How to generate SSL and enable HTTPS protocol with Apache 2 on Ubuntu 21

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

image 26 - How to generate SSL and enable HTTPS protocol with Apache 2 on Ubuntu 21

#2 Change VirtualHost file

nano /etc/apache2/sites-available/default-ssl.conf

add the path to the fullchain and privkey files:

image 25 - How to generate SSL and enable HTTPS protocol with Apache 2 on Ubuntu 21

#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

whoami
Stefan Pejcic
Join the discussion

I enjoy constructive responses and professional comments to my posts, and invite anyone to comment or link to my site.