Setting up a secure website is essential in today's digital world. Using a free SSL/TLS certificate from Let's Encrypt is an excellent way to encrypt your data and protect your visitors. This guide will walk you through the process of installing a Let's Encrypt certificate on a Raspberry Pi web server.

Prerequisites

  • A Raspberry Pi running Raspbian or another Linux-based OS
  • Root or sudo access to the Raspberry Pi
  • A domain name pointing to your Raspberry Pi's IP address
  • Apache or Nginx web server installed
  • Updated system packages

Installing Certbot

Certbot is the recommended tool for obtaining and renewing Let's Encrypt certificates. To install Certbot, run the following commands:

For Raspbian/Debian:

sudo apt update

sudo apt install certbot python3-certbot-nginx

Obtaining a Certificate

Once Certbot is installed, you can request a certificate for your domain. Replace yourdomain.com with your actual domain name:

sudo certbot --nginx -d yourdomain.com -d www.yourdomain.com

If you use Apache, replace --nginx with --apache.

Verifying the Certificate

After running the command, Certbot will automatically configure your web server to use the new certificate. You can verify the installation by visiting https://yourdomain.com in your browser. Look for the padlock icon indicating a secure connection.

Renewing the Certificate

Let's Encrypt certificates are valid for 90 days. Certbot sets up automatic renewal by default. To test renewal, run:

sudo certbot renew --dry-run

Troubleshooting Tips

  • Ensure your domain points correctly to your Raspberry Pi's IP address.
  • Check your web server configuration if Certbot cannot automatically modify it.
  • Make sure ports 80 and 443 are open in your firewall settings.
  • Review Certbot logs located in /var/log/letsencrypt/ for errors.

By following these steps, you can successfully secure your Raspberry Pi web server with a free Let's Encrypt certificate, providing peace of mind for you and your visitors.