Securing your website is essential for protecting user data and building trust. One effective way to do this is by installing an SSL certificate. Let's Encrypt offers free SSL certificates that are easy to set up on a VPS running Ubuntu. This guide walks you through the process of generating and installing a Let's Encrypt SSL certificate on your server.
Prerequisites
- A VPS running Ubuntu (18.04, 20.04, or later)
- Root or sudo access to the server
- A registered domain name pointing to your server's IP address
- Apache or Nginx web server installed
Step 1: Update Your Server
Before starting, update your server packages to ensure everything is current. Run the following commands:
sudo apt update && sudo apt upgrade -y
Step 2: Install Certbot
Certbot is the recommended tool for obtaining and renewing Let's Encrypt certificates. Install it with:
sudo apt install certbot python3-certbot-nginx
Step 3: Obtain the SSL Certificate
Use Certbot to request a certificate for your domain. Replace yourdomain.com with your actual domain name:
sudo certbot --nginx -d yourdomain.com -d www.yourdomain.com
Follow the prompts to complete the process. Certbot will automatically configure your web server to use the new certificate.
Step 4: Verify the Certificate Installation
After installation, check your website using a browser. You should see a padlock icon indicating a secure connection. You can also verify with an online SSL checker tool.
Step 5: Set Up Automatic Renewal
Certbot sets up automatic renewal by default. To test renewal, run:
sudo certbot renew --dry-run
If the test succeeds, your certificate will renew automatically before expiration.
Conclusion
Installing a Let's Encrypt SSL certificate on your Ubuntu VPS enhances your website's security. With Certbot, the process is straightforward and automated. Regularly check your certificate's status and ensure your server remains secure.