DEV Community

Radhakishan Jangid
Radhakishan Jangid

Posted on

Add free ssl on apache2 server ubuntu

नमस्ते 🙏

Free free free 🤩 🥳

Run following command to install free certificate on apache2 server.

Run this command to update existing packages.

sudo apt update
Enter fullscreen mode Exit fullscreen mode

Run this command to install certbot, which provides free certificate for 1 year.

sudo apt install certbot python3-certbot-apache
Enter fullscreen mode Exit fullscreen mode

After successfully installation run this command to get free ssl

sudo certbot --apache
Enter fullscreen mode Exit fullscreen mode

After, enter an email address to get notification when your ssl is about to expire.

article-1

Agree to their terms and condition.

Enter your domain where you wants to install ssl.

article-2

Congratulations! You have successfully installed free certificate on your domain.

Verifying Certbot Auto-Renewal

To auto renewal run following commands:

sudo systemctl status certbot.timer
Enter fullscreen mode Exit fullscreen mode

Your output will be similar to the following:

Output
● certbot.timer - Run certbot twice daily
     Loaded: loaded (/lib/systemd/system/certbot.timer; enabled; vendor preset:>
     Active: active (waiting) since Mon 2022-04-11 20:52:46 UTC; 4min 3s ago
    Trigger: Tue 2022-04-12 00:56:55 UTC; 4h 0min left
   Triggers: ● certbot.service

Apr 11 20:52:46 jammy-encrypt systemd[1]: Started Run certbot twice daily.
Enter fullscreen mode Exit fullscreen mode

To test the renewal process, you can do a dry run with certbot:

sudo certbot renew --dry-run
Enter fullscreen mode Exit fullscreen mode
Output
Saving debug log to /var/log/letsencrypt/letsencrypt.log

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Processing /etc/letsencrypt/renewal/your_domain.conf
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Account registered.
Simulating renewal of an existing certificate for your_domain and www.your_domain.com

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Congratulations, all simulated renewals succeeded:
  /etc/letsencrypt/live/your_domain/fullchain.pem (success)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Enter fullscreen mode Exit fullscreen mode

If you don’t receive any errors, you’re all set. When necessary, Certbot will renew your certificates and reload Apache to pick up the changes. If the automated renewal process ever fails, Let’s Encrypt will send a message to the email you specified, warning you when your certificate is about to expire.

Top comments (1)

Collapse
 
olsard profile image
olsard

Thanks a lot for sharing. Useful.