How To Install SSL Certificate On CentOS

1 Star2 Stars3 Stars4 Stars5 Stars (1 votes, average: 5.00 out of 5)
Install SSL On CentOS

Step-By-Step Process: SSL Certificate Installation on CentOS

Read this installation guide till the end to learn every step and command needed to install an SSL certificate on CentOS. From the prerequisites for the installation procedure to testing the installation, learn everything here.

Prerequisites For Installing an SSL Certificate on CentOS

Firstly, get access to a CentOS server. Not just that, get access with a non-root user that comes with sudo privileges. Not done with this configuration yet. No problem, as you can do it within an hour. Another thing you need to have is your Apache installed. To install your Apache web server with CentOS, check this guide that we prepared separately for you.

Steps for Generating a CSR

Generating a CSR (Certificate Signing Request) is much like a necessity as you need to send it to the Certificate Authority (CA) when applying for an SSL certificate. Not only does a CSR comprises all updated details about your organization or website, but it also consists of the private key. Use our free CSR Generator tool to create the CSR and Private Key.

Read our CentOS CSR Generation guide if you wish to generate it using OpenSSL Command.

Steps to SSL Certificate Installation on CentOS 8

Step 1: Install mod_ssl On Your System

Run this command to check if it’s installed or not.

rpm -qa | grep mod_ssl

Not installed? Use this command to install mod_ssl.

dnf install mod_ssl

Step 2: Create SSL Certificate Chain

The chain must comprise the private key along with the server, intermediate, and root certificates. To do so, run this command:

cat pub-key.pem ca-chain.pem > full-chain.pem

Go to your Apache server and keep the PEM file along with the SSL chain here:


Go to this folder to keep the private key:


If you want your private key to be inaccessible to others, secure it using this command:

chmod -R 600 /etc/pki/tls/private/

Step 3: Virtual Host Block Configuration

Use the following block of code in your domain’s configuration file that comes with a .conf extension.

DocumentRoot /var/www/

You’ll have to use your actual domain name and replace it with ‘’ here. However, you may lack a configuration file. If so, create it using this command:

nano /etc/httpd/conf.d/domainname.conf

Once done, place the file in the following:

/etc/httpd/conf.d/ directory

In your .conf file, add HTTPs redirects using this command:

Redirect "/" ""

Finally, close the file but make sure you save all the changes before that.

Step 4: Restart & Done!

To restart the Apache server, run this command:

systemctl restart httpd

If it restarts successfully, the installation is complete.

SSL Installation for CentOS 7 & 6

Step 1: Downloading Certificates

Received the intermediate and primary certificates from your SSL provider? Now download them all.

Step 2: Copying the SSL Files

When copying the SSL files to your Apache server, ensure including the .key file that you acquired while generating the CSR code.

Step 3: Go to The Apache Configuration & Find and Edit The ssl.conf or httpd.conf File

To do so, run the following nano and cp commands:

# cp /etc/httpd/conf.d/ssl.conf /etc/httpd/conf.d/ssl.conf.BAK
# nano /etc/httpd/conf.d/ssl.conf

You may find that single or many files are commented out. If that happens – depending on your Apache version – delete the # character from the starting line. Then, enter the absolute path.

This block of code below illustrates the absolute file path of your certificates. However, before you copy-paste the thing, ensure to replace the files with the correct actual names.

SSLCertificateFile /etc/httpd/conf/ssl.crt/leaf_certificate.crt SSLCertificateKeyFile /etc/httpd/conf/ssl.key/ABC.key
SSLCACertificatePath /etc/httpd/conf/ssl.chain/intermediate_chain.crt

Keep in mind that you need to change the certificate key file’s permission. To do so, use this command:

# chmod 400 /etc/httpd/conf/ssl.key/

Step 4: Restart the Server!

Now that you’re done, restart the Apache server. Make sure you save all the configurations before restarting the server. Once done, the installation is complete.

<?xml version="1.0" encoding="UTF-8"?><svg id="Layer_1" xmlns="" viewBox="0 0 109.7 29.02"><defs><style>.cls-1{fill:#fff;}</style></defs><path class="cls-1" d="m5.38,22.85c-3.1-.26-5.3-1.92-5.38-4.8h3.6c.1,1.1.67,1.85,1.78,2.09v-4.58c-2.47-.62-5.38-1.32-5.38-4.87,0-2.83,2.26-4.68,5.38-4.92v-1.94h1.54v1.94c3,.24,5.02,1.85,5.23,4.7h-3.62c-.1-.94-.67-1.66-1.61-1.94v4.54c2.5.65,5.42,1.3,5.42,4.85,0,2.45-1.92,4.73-5.42,4.97v1.94h-1.54v-1.97Zm0-10.25v-4.15c-1.1.17-1.87.84-1.87,2.06,0,1.13.77,1.7,1.87,2.09Zm1.54,3.38v4.2c1.22-.22,1.94-1.06,1.94-2.14s-.82-1.68-1.94-2.06Z"/><path class="cls-1" d="m17.62,8.33h-2.33v-3.1h5.78v17.5h-3.46v-14.4Z"/><path class="cls-1" d="m28.27,17.81c.26,1.39,1.15,2.18,2.71,2.18,1.97,0,2.83-1.46,2.83-5.4-.74,1.03-2.16,1.63-3.7,1.63-3.02,0-5.45-1.9-5.45-5.59,0-3.5,2.21-5.81,5.91-5.81,4.75,0,6.22,3.22,6.22,8.76,0,5.95-1.32,9.17-5.95,9.17-3.72,0-5.5-2.38-5.69-4.94h3.12Zm5.23-7.15c0-1.92-1.1-2.98-2.81-2.98s-2.81,1.18-2.81,2.93c0,1.58.89,2.88,2.93,2.88,1.68,0,2.69-1.13,2.69-2.83Z"/><path class="cls-1" d="m41.28,22.9c-1.22,0-2.09-.86-2.09-1.97s.86-1.97,2.09-1.97,2.04.86,2.04,1.97-.86,1.97-2.04,1.97Z"/><path class="cls-1" d="m49.54,17.81c.26,1.39,1.15,2.18,2.71,2.18,1.97,0,2.83-1.46,2.83-5.4-.74,1.03-2.16,1.63-3.7,1.63-3.02,0-5.45-1.9-5.45-5.59,0-3.5,2.21-5.81,5.91-5.81,4.75,0,6.22,3.22,6.22,8.76,0,5.95-1.32,9.17-5.95,9.17-3.72,0-5.5-2.38-5.69-4.94h3.12Zm5.23-7.15c0-1.92-1.1-2.98-2.81-2.98s-2.81,1.18-2.81,2.93c0,1.58.89,2.88,2.93,2.88,1.68,0,2.69-1.13,2.69-2.83Z"/><path class="cls-1" d="m64.56,17.81c.26,1.39,1.15,2.18,2.71,2.18,1.97,0,2.83-1.46,2.83-5.4-.74,1.03-2.16,1.63-3.7,1.63-3.02,0-5.45-1.9-5.45-5.59,0-3.5,2.21-5.81,5.9-5.81,4.75,0,6.22,3.22,6.22,8.76,0,5.95-1.32,9.17-5.95,9.17-3.72,0-5.5-2.38-5.69-4.94h3.12Zm5.23-7.15c0-1.92-1.1-2.98-2.81-2.98s-2.81,1.18-2.81,2.93c0,1.58.89,2.88,2.93,2.88,1.68,0,2.69-1.13,2.69-2.83Z"/><path class="cls-1" d="m81.79,0h3.29l-6.48,27.07h-3.29L81.79,0Z"/><path class="cls-1" d="m96.89,9.43h3.58l-8.23,19.59h-3.58l2.88-6.62-5.33-12.96h3.77l3.43,9.29,3.48-9.29Z"/><path class="cls-1" d="m105.62,22.73h-3.36v-13.3h3.36v2.06c.84-1.37,2.23-2.26,4.08-2.26v3.53h-.89c-1.99,0-3.19.77-3.19,3.34v6.62Z"/></svg>