Configure Apache to use the SSL Certificate

Configure Apache to use the SSL Certificate

SSL Certificates with Apache on Debian & Ubuntu

  • Edit the virtual host configuration files located in /etc/apache2/sites-available, to provide the certificate file paths. For each virtual host, replicate the configuration shown below. Replace any mentions of sysadmin.com with your own domain. You will also need to ensure that theSSLCACertificateFile value is configured to point to the CA root certificate downloaded in the previous step:

Apache virtual hosting file

<VirtualHost *:443>

SSLEngine On

SSLCertificateFile /etc/ssl/localcerts/www.sysadmin.com.crt

SSLCertificateKeyFile /etc/ssl/localcerts/www.sysadmin.com.key

SSLCACertificateFile /etc/ssl/localcerts/ca.pem  # If using a self-signed certificate, omit this line

 

ServerAdmin info@sysadmin.com

ServerName www.sysadmin.com

DocumentRoot /var/www/sysadmin.com/public_html/

ErrorLog /var/www/sysadmin.com/log/error.log

CustomLog /var/www/sysadmin.com/log/access.log combined

</VirtualHost>

  • Ensure that the Apache SSL module is enabled:
# a2enmod ssl
  • Restart Apache:
# service apache2 restart

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

 

SSL Certificates with Apache on CentOS 7

 

In order to configure SSL, you will need to ensure that mod_ssl and OpenSSL are installed on your system. You can do so by running the following command:

# yum install mod_ssl openssl

 

Configure Apache to use the Signed SSL Certificate

  • Edit the virtual host entries in the /etc/httpd/conf/httpd.conf file to provide the certificate files that should be used by each domain. For each virtual host, you will need to replicate the configuration shown below. Replace any mentions of sysadmin.com with your own domain. Ensure that the SSLCACertificateFile value is configured to point to the CA root certificate downloaded in the previous step:

/etc/httpd/conf.d/vhost.conf

<VirtualHost *:443>

SSLEngine On

SSLCertificateFile /etc/ssl/localcerts/www.sysadmin.com.crt

SSLCertificateKeyFile /etc/ssl/localcerts/www.sysadmin.com.key

SSLCACertificateFile /etc/ssl/localcerts/ca.pem

 

ServerAdmin info@sysadmin.com

ServerName www.sysadmin.com

DocumentRoot /var/www/sysadmin.com/public_html/

ErrorLog /var/www/sysadmin.com/logs/error.log

CustomLog /var/www/sysadmin.com/logs/access.log combined

</VirtualHost>

  • Restart Apache:
# systemctl restart httpd

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