How to install/download a previous Letsencrypt to a new server (migrate a Letsencrypt certificate)

To migrate a Letsencrypt certificate so that auto-renewal works.

# remove old config files if they are there, otherwise it might create the SSL files under a -0001 directory.

rm -rf /etc/letsencrypt/live/domain.co.uk*

rm -rf /etc/letsencrypt/archive/domain.co.uk*

rm -rf /etc/letsencrypt/renewal/domain.co.uk*

# download the certificate only and restart nginx

certbot certonly --agree-tos --email info@startnet.co.uk --text --webroot --webroot-path /var/www/domain.co.uk -d domain.co.uk

/etc/init.d/nginx restart

# check that auto renewal works

certbot renew --nginx --renew-hook "service nginx restart"

DONE!

Leave a Reply