How Do I Install an SSL Certificate on My Linux Server Using Let's Encrypt?
How do I install an SSL certificate on my Linux server using Let's Encrypt?
Before you install the SSL Certificate, you must have the following:
- A domain name pointing to your server.
- Root or sudo access to the server.
If you have both of the above, then you can follow the guide below to install your SSL certificate. In this guide, we'll use Certbot, a tool that automates the process of obtaining and installing Let's Encrypt SSL Certificates.
- First you must install Certbot, if you're using Ubuntu/Debian run the following command:
sudo apt update
If you're using CentOS/RHEL, run the following command:
sudo apt install certbot python3-certbot-apache # For Apache sudo apt install certbot python3-certbot-nginx # For Nginxsudo yum install epel-release sudo yum install certbot python2-certbot-apache # For Apache sudo yum install certbot python2-certbot-nginx # For Nginx
- Use the command below to get your SSL certificate. Please replace your_domain in the example below with your actual domain.
If you're using Apache, run the following command:sudo certbot --apache -d your_domain -d www.your_domain
If you're using Nginx, run the following the command:sudo certbot --nginx -d your_domain -d www.your_domain
Certbot automatically creates a cron job for certificate renewal. You can test this renewal process with this command:
sudo certbot renew --dry-run
Finally, restart your web server.
If you're using Apache, run the following command:sudo systemctl restart apache2
If you're using Nginx, run the following command:
sudo systemctl restart nginx
Was this article helpful?
That’s Great!
Thank you for your feedback
Sorry! We couldn't be helpful
Thank you for your feedback
Feedback sent
We appreciate your effort and will try to fix the article