To install SSL certificates for website
on an Ubuntu server using the command line, you can use Let's Encrypt with Certbot, which is free and widely supported.
1. Update Ubuntu
sudo apt update && sudo apt upgrade -y 2. Install Certbot For Nginx:
sudo apt install certbot python3-certbot-nginx -y
If you're using Apache:
sudo apt install certbot python3-certbot-apache -y
3. Obtain SSL Certificate
For Nginx:
sudo certbot --nginx -d yourdomain.com -d www.yourdomain.com For Apache:
sudo certbot --apache -d yourdomain.com -d www.yourdomain.com
Follow the prompts:
-
Agree to terms.
-
Enter your email.
-
Optionally redirect HTTP to HTTPS.
4. Verify Installation
sudo certbot certificates
5. Auto-Renewal (Set by default)
Check:
sudo systemctl list-timers
Or run a test renewal:
sudo certbot renew --dry-run
Comments