How to setup LetsEncrypt SSL Certificate for Apache on Debian 10

Install Certbot in Debian 10

First update system repositories.

apt update

Install the certbot package for letsEncrypt

apt install python-certbot-apache

Obtain an SSL certificate for domain.

certbot --apache -d your_domain -d www.your_domain

This will immediately request for your email address

Example

[email protected]:~# certbot --apache -d 193.29.58.131.xip.io
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator apache, Installer apache
Enter email address (used for urgent renewal and security notices) (Enter 'c' to
cancel):

You will be prompted to agree with the Terms of Service. Type A and hit Enter.

Please read the Terms of Service at 
https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf. You must
agree in order to register with the ACME server at
https://acme-v02.api.letsencrypt.org/directory
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(A)gree/(C)ancel:

Type Y and hit Enter.

Would you be willing to share your email address with the Electronic Frontier
Foundation, a founding partner of the Let's Encrypt project and the non-profit
organization that develops Certbot? We'd like to send you email about our work
encrypting the web, EFF news, campaigns, and ways to support digital freedom.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o:

Certbot will contact Let’s encrypt servers and verify of the domain you are requesting for is a registered and valid domain.

Obtaining a new certificate
Performing the following challenges:
http-01 challenge for 193.29.58.131.xip.io
Enabled Apache rewrite module
Waiting for verification...
Cleaning up challenges
Created an SSL vhost at /etc/apache2/sites-available/000-default-le-ssl.conf
Enabled Apache socache_shmcb module
Enabled Apache ssl module

To encrypt HTTP access, type 2 for redirection and hit ENTER.

What would you like to do?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: Attempt to reinstall this existing certificate
2: Renew & replace the cert (limit ~5 per 7 days)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate number [1-2] then [enter] (press 'c' to cancel):

you will get the notification below that you have successfully enabled the HTTPS protocol on your web server and the expiry date of your SSL certificate.

The new certificate covers the following domains: https://193.29.58.131.xip.io
You should test your configuration at:
https://www.ssllabs.com/ssltest/analyze.html?d=193.29.58.131.xip.io
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
IMPORTANT NOTES:
- Congratulations! Your certificate and chain have been saved at:
/etc/letsencrypt/live/193.29.58.131.xip.io/fullchain.pem
Your key file has been saved at:
/etc/letsencrypt/live/193.29.58.131.xip.io/privkey.pem
Your cert will expire on 2020-01-31. To obtain a new or tweaked
version of this certificate in the future, simply run certbot again
with the "certonly" option. To non-interactively renew *all* of
your certificates, run "certbot renew"
- If you like Certbot, please consider supporting our work by:
Donating to ISRG / Let's Encrypt:   https://letsencrypt.org/donate
Donating to EFF:                    https://eff.org/donate-le

Allow HTTPS protocol On firewall

You need to allow HTTPS traffic through it.

ufw allow 443/tcp

Output:

[email protected]:~# ufw allow 443/tcp
Rules updated
Rules updated (v6)

Verify HTTPS on Website

https://<Your_domain_name>

Checking auto renew certbot SSL certificate

Certbot automatically renews the SSL certificate 30 days prior to its expiration. To verify the renewal process.

certbot renew --dry-run

Output:

[email protected]:~# certbot renew --dry-run
Saving debug log to /var/log/letsencrypt/letsencrypt.log
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -                                                                                           -
Processing /etc/letsencrypt/renewal/193.29.58.131.xip.io.conf
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -                                                                                           -
Cert not due for renewal, but simulating renewal for dry run
Plugins selected: Authenticator apache, Installer apache
Renewing an existing certificate
Performing the following challenges:
http-01 challenge for 193.29.58.131.xip.io
Waiting for verification...
Cleaning up challenges
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -                                                                                           -
new certificate deployed with reload of apache server; fullchain is
/etc/letsencrypt/live/193.29.58.131.xip.io/fullchain.pem
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -                                                                                           -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -                                                                                           -
** DRY RUN: simulating 'certbot renew' close to cert expiry
**          (The test certificates below have not been saved.)
Congratulations, all renewals succeeded. The following certs have been renewed                                                                                          :
/etc/letsencrypt/live/193.29.58.131.xip.io/fullchain.pem (success)
** DRY RUN: simulating 'certbot renew' close to cert expiry
**          (The test certificates above have not been saved.)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -                                                                                           -
IMPORTANT NOTES:
- Your account credentials have been saved in your Certbot
configuration directory at /etc/letsencrypt. You should make a
secure backup of this folder now. This configuration directory will
also contain certificates and private keys obtained by Certbot so
making regular backups of this folder is ideal.
[email protected]:~#