Skip to content

Instantly share code, notes, and snippets.

@ifranco88
Last active April 21, 2018 09:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ifranco88/3019f8dbe64d075e0e0023af356cfe25 to your computer and use it in GitHub Desktop.
Save ifranco88/3019f8dbe64d075e0e0023af356cfe25 to your computer and use it in GitHub Desktop.
Enable SSL Signed Certificate with Apache on Ubuntu 16.04

Enable SSL Signed Certificate with Apache on Ubuntu 16.04

Let's Encrypt certificates it is a service that provides certificates via the Certbot client software running on your server.

Installing the Let's Encrypt Client

Add the repository

$ sudo add-apt-repository ppa:certbot/certbot

Update Ubuntu repositories

$ sudo apt-get update

Install Certbot from repository

$ sudo apt-get install python-certbot-apache

Firewall

If you have the ufw firewall enabled you have to ensure that your server allow SSL traffic.

$ sudo ufw status

Setting up the SSL certificate

Generate the SSL certificate using Certbot.

After run the below command, you should follow the step-by-step guide to customize your certificate options.

$ sudo certbot --authenticator standalone --installer apache -d example.com -d www.example.com --pre-hook "service apache2 stop" --post-hook "service apache2 start"

Note: The apache service should be stopped. Otherwise the Certbot will not be able to binding the server ports.

If everithing is fine, your web server will be able to serve SSL requests.

You can test it, acessing to https://example.com

Certbot Renewal certificate

The Certbot provides a cron in charge of renewal any certificate that's within thirty days of expiration.

You can test the renewal process run:

$ sudo certbot renew --dry-run --pre-hook "service apache2 stop" --post-hook "service apache2 start"

If you have problems to renew the certificate with previous command you can force the renewal run:

$ sudo certbot certonly --force-renew --apache --cert-name example.com -d example.com -d www.example.com

Credits

This information is extracted from the following links:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment