How to install Certbot on your Linux VPS
Instructions for installing Certbot for Apache2 and Nginx on a Linux VPS.
With Certbot you can set up free TLS/SSL certificates from Let's Encrypt.
Certbot via Snap (recommended)
Update system
First update the system of your server. Open the console and enter the following command:bashapt update && apt upgrade -yapt update && apt upgrade -yInstall Snap
Install Snap by entering the following commands in the console:bashsudo apt install snapd sudo snap install core sudo snap refresh coresudo apt install snapd sudo snap install core sudo snap refresh coreInstall Certbot
Install Certbot via Snap:bashsudo snap install --classic certbotsudo snap install --classic certbotEnable command
Make the Certbot command available system-wide:bashsudo ln -s /snap/bin/certbot /usr/bin/certbotsudo ln -s /snap/bin/certbot /usr/bin/certbotUse Certbot
Run Certbot for your web server:- For Apache2:
bashsudo certbot --apachesudo certbot --apache- For Nginx:
bashsudo certbot --nginxsudo certbot --nginxCheck certificates
You can find certificates under:/etc/letsencrypt/live/<your-domain>//etc/letsencrypt/live/<your-domain>/Show status:
bashsudo certbot certificatessudo certbot certificatesAutomatic renewal
Certbot automatically creates a cronjob. You can use the following command to test whether the automatic renewal works correctly:bashsudo certbot renew --dry-runsudo certbot renew --dry-run
Certbot via APT
Note
This method often installs outdated versions. Only use it if Snap is not possible.
Update system
First update the system of your server. Open the console and enter the following command:bashapt update && apt upgrade -yapt update && apt upgrade -yInstall Certbot
Install Certbot for your web server:- For Apache2:
bashsudo apt install certbot python3-certbot-apachesudo apt install certbot python3-certbot-apache- For Nginx:
bashsudo apt install certbot python3-certbot-nginxsudo apt install certbot python3-certbot-nginxUse Certbot
Run Certbot for your web server:- For Apache2:
bashsudo certbot --apachesudo certbot --apache- For Nginx:
bashsudo certbot --nginxsudo certbot --nginxCheck certificates
You can find certificates under:/etc/letsencrypt/live/<your-domain>//etc/letsencrypt/live/<your-domain>/Show status:
bashsudo certbot certificatessudo certbot certificatesAutomatic renewal
Certbot automatically creates a cronjob. You can use the following command to test whether the automatic renewal works correctly:bashsudo certbot renew --dry-runsudo certbot renew --dry-run
Important
The domain must point to the server (A or AAAA entry), and port 80 (HTTP challenge) must be accessible - otherwise the validation will fail.