Secure certificates for all sites on Apache server quickly

  1. Couple of things all domains for the sites under sites-enabled need to point to the server. Including all aliases
  2. Main cert will be issued to the first domain it finds alphabetically. All other domains will be alternative names. Think ahead on this one. If your first sites is andy55.com then the cert will be issued to andy55.com and again any other sites/domains will be alternative names on that cert.
  3. Add Certbot PPAYou’ll need to add the Certbot PPA to your list of repositories. To do so, run the following commands on the command line on the machine:
    1. sudo apt-get update
    2. sudo apt-get install software-properties-common
    3. sudo add-apt-repository universe
    4. sudo add-apt-repository ppa:certbot/certbot
    5. sudo apt-get update
  4. Install CertbotRun this command on the command line on the machine to install Certbot.
    1. sudo apt-get install certbot python-certbot-apache
  5. Choose how you’d like to run Certbot
    • Either get and install your certificates…Run this command to get a certificate and have Certbot edit your Apache configuration automatically to serve it, turning on HTTPS access in a single step. Don’t forget option 2 at the end to allow is to add the redirect stuff automatically for you.
      • sudo certbot –apache
      • This will show a list of all domains simply type the number of the domains you want.
      • option 2 is to put the domains on the line
      • sudo certbot –apache -d domain.com -d www.domain.com
  6. Test automatic renewal
  7. The Certbot packages on your system come with a cron job or systemd timer that will renew your certificates automatically before they expire. You will not need to run Certbot again, unless you change your configuration. You can test automatic renewal for your certificates by running this command:
    1. sudo certbot renew –dry-run
    2. The command to renew certbot is installed in one of the following locations:
    • /etc/crontab/
    • /etc/cron.*/*
    • systemctl list-timers