What you’ll learnIn this tutorial, you will learn the procedure of TLS/SSL certificate installation on Apache web server running on Centos 7. Once you are finished, all traffic between server and client will be encrypted and safe. This is a standard practice of securing e-commerce websites and other financial services online.
What you’ll needBefore you begin working with this guide you’ll need these:
- SSH with Root user access to the CentOS 7 VPS
- The Apache web server with properly a domain and vhost configure
Step 1 — Installing dependent modulesAfter ssh as root to the centos vps you need to install certbot so you will have to install EPEL repository as it’s not available by default and the mod_ssl module is a must for the encryption to be recognized in Apache.To install both these dependencies, please run this command:
yum install epel-release mod_sslNow you should be ready to proceed further and install the certbot itself.
Step 2 — Downloading the Let’s Encrypt clientTo install the certbot client from EPEL repository run this:
yum install python-certbot-apacheWithin a few time the certbot should be installed and available for actual use.
Step 3 — Create and install the SSL certificate(s)Certbot will handle the SSL certifcate management quite easily, it will generate anew certificate for a provided domain as a parameter.In this case, example.com will be used as the domain for which the certificate will be issued:
certbot --apache -d example.comIf you want to generate SSL for multiple domains or subdomains, please run this command:
certbot --apache -d example.com -d www.example.comIMPORTANT! The first domain should be your base domain, in this sample it’s example.comWhile installing the certificate you will be presented with a step-by-step guide whichwill let you customize certificate details. You will be able to choose between forcingHTTPS or leaving HTTP as the default protocol, providing an email address will berequired as well for security purposes.Once the installation completes, you should be presented with similar message:
Step 4 — Setting up for the auto renewalLet’s Encrypt certificates are valid for 90 days only, but every web professionals will recommend you to renew it within 75 days in order to avoid any issues. To accomplish this, the certbot will help us with its renew command. It will check if the certificate is less than 15 days away from expiration.Please run this command to proceed:
certbot renewIf the installed certificate is recent, the certbot will only check for its expiration date:
crontab -eThis job can be safely scheduled to run every Monday at midnight:
0 0 * * 1 /usr/bin/certbot renew >> /var/log/sslrenew.logThe output of the script will be piped to /var/log/sslrenew.log file.Finally You have just secured your Apache web server by implementing the most anticipated security feature – free SSL certificates! From now on all trafc between your domain webserver and client is secure, you can be assured that no one could intercept the communication and alter or steal crucial information. 😀Happy Hacking!