sudo apt update sudo apt install python3 python3-dev python3-venv libaugeas-dev gcc # Set up a Python virtual environment sudo python3 -m venv /opt/certbot/ sudo /opt/certbot/bin/pip install --upgrade pip # Install certbot sudo /opt/certbot/bin/pip install certbot certbot-nginx sudo certbot --nginx # If you're feeling more conservative and would like to make the changes to your nginx configuration by hand, run this command. sudo certbot certonly --nginx # Set up automatic renewal echo "0 0,12 * * * root /opt/certbot/bin/python -c 'import random; import time; time.sleep(random.random() * 3600)' && sudo certbot renew -q" | sudo tee -a /etc/crontab > /dev/null # [Monthly] Upgrade certbot sudo /opt/certbot/bin/pip install --upgrade certbot certbot-nginx # If this step leads to errors, run sudo rm -rf /opt/certbot and repeat all installation instructions.