SSL Certificates with Apache on CentOS 7

Posted on

SSL Certificates with Apache on CentOS 7

SSL Certificates with Apache on CentOS 7

This guide will show you how to enable SSL to secure websites served through Apache on CentOS or Fedora.

Before You Begin

This guide assumes that you are running Apache2 on CentOS or Fedora. Prior to starting this guide, ensure that the following steps have been taken on your Linode:

  • Familiarize yourself with our Getting Started guide and complete the steps for setting your Linode’s hostname and timezone.

  • Complete our LAMP on CentOS 7 guide, and create a site that you wish to secure with SSL.

  • Follow our guide for obtaining either a self-signed or commercial SSL certificate.

  • In order to configure your Linode to function with SSL, you will need to ensure that the Apache mod_ssl module is installed on your system. You can do so by running the following command:

    yum install mod_ssl

Configure Apache to use the SSL Certificate

  1. Edit the virtual host entries in the /etc/httpd/conf.d/ssl.conf file to include the certificate files and virtual host information that should be used by each domain. For each virtual host, replicate the configuration shown below. Replace each mention of with your own domain.

    If you’re using a commercially signed certificate and you’ve manually downloaded the root CA cert to /etc/pki/tls/certs, ensure that the SSLCACertificateFile value is configured to point to the root certificate directly. If the root certificate is being provided via the “ca-certificates” bundle, you can simply exclude the SSLCACertificateFile line.

    <VirtualHost *:443>
         SSLEngine On
         SSLCertificateFile /etc/pki/tls/certs/
         SSLCertificateKeyFile /etc/pki/tls/private/
         SSLCACertificateFile /etc/pki/tls/certs/root-certificate.crt  #If using a self-signed certificate or a root certificate provided by ca-certificates, omit this line
         DocumentRoot /var/www/
         ErrorLog /var/www/
         CustomLog /var/www/ combined
  2. Restart Apache:

    systemctl restart httpd

You should now be able to visit your site with SSL enabled.

Test Your Configuration

Test your SSL configuration using the test page at your certificate issuer’s website, then perform a deep analysis through the Qualys SSL Labs SSL Server Test

More Information

You may wish to consult the following resources for additional information on this topic. While these are provided in the hope that they will be useful, please note that we cannot vouch for the accuracy or timeliness of externally hosted materials.

  • Apache HTTP Server Version 2.0 Documentation
  • Setting up an SSL Secured Webserver with CentOS

Join our Community

Find answers, ask questions, and help others.

This guide is published under a CC BY-ND 4.0 license.

Leave a Reply

Your email address will not be published. Required fields are marked *