How to use LetsEncrypt with Certbot
Certbot is a wonderful tool you can use to: Generate a SSL certificate with LetsEncrypt and automatically install and configure it on your webserver.
Prerequisites
You'll need a website that's already online and hosted on a server. Obviously a domain is also necessary.
Installing Certbot...
on Debian 11/10
First we'll have to install snapd:
Now ensure that your version of snap is up to date by runnig this command:
Make sure to remove any old certbot installations:
Then, install Certbot:
Execute the following command to ensure that the certbot command can be run:
on Ubuntu 20
Ensure that your version of snap is up to date by runnig this command:
Make sure to remove any old certbot installations:
Then, install Certbot:
Execute the following command to ensure that the certbot command can be run:
on CentOS 8
If you don’t already have the CentOS repository added to your distribution, it can be added as follows:
Then, simply install snapd with yum:
Once installed, the systemd unit that manages the main snap communication socket needs to be enabled:
To enable classic snap support, enter the following to create a symbolic link between /var/lib/snapd/snap
and /snap
:
Either log out and back in again or restart your system to ensure snap’s paths are updated correctly.
Now ensure that your version of snap is up to date by runnig this command:
Make sure to remove any old certbot installations:
Then, install Certbot:
Execute the following command to ensure that the certbot command can be run:
Create and install certificate
Just get a certificate
If you don't want to automatically install and configure the certbot certificate, run this command to only generate it:
What to replace your_webserver with
- For apache use
apache
- For nginx use
nginx
- For HAProxy or other
standalone
So for example sudo certbot certonly --nginx
This will just put the certificate and key under /etc/letsencrypt/live/your_domain/
.
Automatically install it
If you want to automatically install and also configure it in your webserver, run this command with your corresponding web server:
What to replace your_webserver with
- For apache use
apache
- For nginx use
nginx
- For HAProxy or other
webroot
For examlpe sudo certbot --nginx
Confirm that Certbot worked
To confirm that your site is set up properly, visit https://yourwebsite.com/
in your browser and look for the lock icon in the URL bar.
Conclusion
In this article I showed you: How to install and use Certbot on three different platforms and with three different web servers. If I have helped you, consider signing up for free to get access to all my guides and my newsletter.