Make sure your hostnames resolve to your forum by properly configuring DNS.
for ubuntu+nginx:
sudo apt install python-certbot-nginx
sudo certbot --nginx
for ubuntu+apache:
sudo apt install python-certbot-apache
sudo certbot --apache
(For other installation instructions check the official website at https://certbot.eff.org/)
In the second command from above you are asked to select the hostnames you want to request a certificate for. If they don't resolve the process won't succeed. Once it does succeed it asks you to automatically redirect traffic to https; I suggest you do that, so that you won't need to do any other magic.
Once the certificate has been installed, update your config.php
url value to read https://yourdomain.com
instead of http://yourdomain.com
.
Then update the cronjob to auto renew regularly:
sudo crontab -e
// pick your favorite editor here, I use vim:
// add a line below the comments (vim press "i" to be able to type):
0 1 * * * certbot renew
// (vim press Shift z twice, so "ZZ")
That's it. The above replaces the (now outdated) way that my dear friend Matteo whipped together over two years ago.