Ribbon Icon Celebrating 27 Years – Announcing the new GeoTrust Horizon® platform. Learn More
Home Icon > Resources > Expert Guides > SSL/TLS Installation and Automation > How to Install an SSL Certificate on CentOS 7 (Apache)

How to Install an SSL Certificate on CentOS 7 (Apache)

Securing your CentOS 7 server with an SSL certificate ensures encrypted data transfer and builds trust with your users. In this step-by-step guide, we’ll cover two approaches to install an SSL certificate on CentOS 7 using Apache HTTP server (httpd):

  1. The manual method
  2. The automated method using GeoTrust Horizon’s AutoInstall SSL.

Automate Your SSL Certificate in 5 Minutes

Keep your website secure and online… no manual certificate renewals needed!

Requirements Before You Begin

  • A CentOS 7 server with the Apache HTTP server (httpd) installed
  • Root or sudo privileges
  • A valid SSL/TLS certificate from a publicly trusted certificate authority (CA)

Don’t Have an SSL Certificate?

No worries — you can get one from us at some of the best prices on the internet.

Method 1: Manual Installation on Apache (CentOS 7)

Step 1: Generate a CSR and Private Key for Your Domain

If you haven’t already, generate a certificate signing request (CSR) and private key using OpenSSL:

openssl req -new -newkey rsa:2048 -nodes -keyout securitytest_site.key -out securitytest_site.csr

Follow the prompts to enter your domain details.

A screenshot showing the commands to use when creating a csr and private key in CentOS Apache
Image caption: Examples of the commands and required information fields when creating a CSR and private key using OpenSSL on CentOS 7.

Step 2: Upload the CSR to GeoTrust Horizon and Complete Validation

This next step involves sending your certificate signing request to your certificate provider. If you’ve purchased a certificate from us, you can submit the CSR via the GeoTrust Horizon dashboard.

  1. Log in to GeoTrust Horizon platform dashboard.
  2. Click Add Domain and upload your .csr file.
A demonstration showing how to input a test SSL/TLS certificate's certificate signing request (CSR) data in the GeoTrust Horizon platform's dashboard
Image caption: An example of a test CSR, which includes the —–BEGIN CERTIFICATE REQUEST—– and —–END CERTIFICATE REQUEST—– information tags.
  1. Select a method of domain control validation (ideally, using DNS or HTTP file-based methods).
A demonstration showing where to select your preferred domain control validation (DCV) method, which includes email, DNS, or file-based validation
Image caption: A screenshot showing where you can select your preferred domain control validation method (e.g., file-based validation for non-wildcard SSL/TLS certificates).

Once the domain is verified, download the issued certificate bundle, which includes:

  • Domain certificate: For example, securitytest_site.crt
  • CA certificate bundle (intermediate chain): For example, My_CA_Bundle.ca-bundle

Step 3: Upload Your SSL Certificate and Key Files to the CentOS Server

Use scp (the secure copy protocol) or tools like WinSCP to transfer these files from your local system to the server. Use the following commands. (Note: Be sure to replace the example file names below with your unique file names.)

scp securitytest_site.crt ec2-user@your_server_ip:/home/ec2-user/
scp My_CA_Bundle.ca-bundle ec2-user@your_server_ip:/home/ec2-user/
scp security.test.site.key ec2-user@your_server_ip:/home/ec2-user/

Then move them into appropriate system directories using the following commands:

sudo mv securitytest_site.crt /etc/pki/tls/certs/
sudo mv My_CA_Bundle.ca-bundle /etc/pki/tls/certs/
sudo mv security.test.site.key /etc/pki/tls/private/

Set the correct permissions for the specified files:

sudo chmod 644 /etc/pki/tls/certs/*.crt
sudo chmod 600 /etc/pki/tls/private/*.key

Step 4: Create a FullChain File Required by Apache

Apache expects a complete certificate chain for proper SSL validation. Combine your domain certificate and CA bundle using the following command (again, replacing the generic values with your unique file names):

sudo bash -c 'cat /etc/pki/tls/certs/securitytest_site.crt /etc/pki/tls/certs/My_CA_Bundle.ca-bundle > /etc/pki/tls/certs/fullchain.pem'
A terminal screenshot in CentOS illustrating how to create a fullchain file by combining the server certificate and CA bundle file
Image caption: You can create the fullchain.pem file by combining the server certificate and CA bundle file.

Alternatively, if you’re running an older version of Apache and need to upload the separate files, you can do so using the following command:

SSLCertificateFile /etc/httpd/conf.d/yourdomain.crt
SSLCertificateChainFile /etc/httpd/conf.d/ca_bundle.ca-bundle
SSLCertificateKeyFile /etc/httpd/conf.d/private.key

Step 5: Update Apache Configuration to Use the SSL Certificate

To enable SSL in Apache2 CentOS 7, you must edit the Apache SSL configuration file:

sudo nano /etc/httpd/conf.d/ssl.conf

In it, replace or update the <VirtualHost *:443> block to include the specified SSLCertificateFile and SSLCertificateKeyFile information:

<VirtualHost *:443>
    ServerName securitytest.site
    DocumentRoot /var/www/html

    SSLEngine on
    SSLCertificateFile /etc/pki/tls/certs/fullchain.pem
    SSLCertificateKeyFile /etc/pki/tls/private/security.test.site.key

    ErrorLog /var/log/httpd/securitytest.site.error.log
    CustomLog /var/log/httpd/securitytest.site.access.log combined
</VirtualHost>
A screenshot showing how to configure the VirtualHost block with the fullchain.pem file
Image caption: An example of an Apache server that’s configured to use SSL with the fullchain bundle and key.

Step 6: Check Apache Configuration for Syntax Errors

Run the following command to test your configuration file for any issues:

sudo apachectl configtest

Here’s what you should expect to see:

Syntax OK

Step 7: Restart Apache and Enable it on Boot

Restart your Apache server to apply the changes to its SSL configuration:

sudo systemctl restart httpd

Enable Apache to run at startup:

sudo systemctl enable httpd

Step 8: Verify HTTPS Access in a Browser

Once you’ve rebooted your web server, you’ll want to test your domain in a browser to see whether HTTPS is enabled. If it is, you should see a secure padlock icon in the address bar (depending on the browser) or a message stating that your connection is secure.

A screenshot demonstrating what it looks like when an SSL certificate has been installed successfully and HTTPS is enabled on a website
Image caption: A screenshot of a test website displaying the HTTPS secure padlock, which indicates that the website has SSL/TLS enabled.

To troubleshoot, test SSL using:

openssl s_client -connect <website>:443 -servername <website>

Automate Your SSL Certificate in 5 Minutes

Keep your website secure and online… no manual certificate renewals needed!

Method 2: Automate SSL on CentOS 7 Using AutoInstall SSL

GeoTrust Horizon simplifies SSL deployment with an automated installation script for Apache. Here’s how to use it:

Step 1: Add Your Domain in GeoTrust Horizon

Log into GeoTrust Horizon, click Add Domain, and follow the prompts. This includes selecting Automatic Installation as your preferred method.

A screenshot illustrating how to select SSL automation in the GeoTrust Horizon dashboard
Image caption: A screenshot showing how to choose the use of SSL automation on your server in the GeoTrust Horizon dashboard.

Step 2: Complete the CSR Generation and Domain Validation Processes

GeoTrust Horizon will walk you through the processes of generating a CSR and verifying your domain ownership (via DNS or file-based validation). To start the process, select your server type as shown below, as shown in the screenshot below:

This screenshot shows how to select your Linux system (e.g., Apache for CentOS 7) in the GeoTrust Horizon platform's dashboard when preparing to install an SSL certificate
Image caption: A screenshot showing how to specify your server type in the GeoTrust Horizon dashboard.

Next, select your preferred method of domain control validation.

A demonstration showing where to select your preferred domain control validation (DCV) method, which includes email, DNS, or file-based validation
Image caption: This example shows how to select the file validation method in GeoTrust Horizon’s dashboard.

Step 3: Download and Run the Agent and Certificate Installation Script

Once verified, GeoTrust Horizon will generate a customized installation script that automatically:

  • Installs the certificate,
  • Creates and configures the SSL virtual host, and
  • Restarts the Apache service.

To initiate this process, all you must do is enter the following command:

sudo wget -qO - https://files.autoinstallssl.com/packages/linux/version/latest/get.autoinstallssl.sh | sudo bash -s

To execute it, enter the following command, which will include your AutoInstall SSL token:

sudo runautoinstallssl.sh installcertificate --token <tokenvalue> --validationtype file --validationprovider filesystem
A screenshot of an Apache terminal displaying the execution of the GeoTrust Horizon AutoInstall SSL installation script
Image caption: A screenshot of an auto-installation script running on CentOS 7 that sets up AutoInstall SSL.Once this is done, simply visit your site to check whether your site is listed as secure in your preferred browser.
A screenshot demonstrating what happens after GeoTrust Horizon's AutoInstall SSL agent successfully installs an SSL certificate using automation
Image caption: A screenshot showing the successful installation of the SSL certificate on a CentOS 7 Apache server using AutoInstall SSL.

That’s it! This means you can set AutoInstall SSL up once and it’ll take care of these monotonous tasks for you from now on. As you can see, using AutoInstall SSL to install an SSL certificate on a CentOS 7 Apache server is fast and easy.

SSL automation gives you back time that can be spent on other tasks that require your human ingenuity, skills, and critical thinking.

Common Questions and Troubleshooting

Why does Apache return a ‘Failed to configure CA certificate chain’ message?

This error typically inicates one of the following issues:

  • Your CA chain file is missing or incorrect
  • The fullchain file (if you used one) is incomplete or misconfigured

Ensure the certificate and chain are properly combined as shown in Step 4.

Can I use a combined fullchain instead of separate files?

Yes! Doing so is recommended for modern Apache versions (although it’s not technically a requirement). Run:

sudo bash -c 'cat /etc/pki/tls/certs/securitytest_site.crt /etc/pki/tls/certs/My_CA_Bundle.ca-bundle > /etc/pki/tls/certs/fullchain.pem'

Then update your Apache configuration:

SSLCertificateFile /etc/pki/tls/certs/fullchain.pem

You can remove SSLCertificateChainFile if using the fullchain.

What if my browser says the site is still “Not Secure”?

Try the following:

  • Clear browser cache or test in Incognito
  • Review your Apache logs: sudo tail -n 30 /var/log/httpd/securitytest.site.error.log
  • Use openssl s_client to verify the SSL chain

Tips for Managing and Renewing SSL on CentOS

  • Renew your SSL/TLS certificate 30 days before it’s set to expire.
  • Use GeoTrust Horizon’s auto-renew feature to avoid manual reconfiguration.
  • Back up your .crt, .key, and .pem files securely.
  • Monitor your SSL/TLS status using an online tool, such as GeoTrust Horizon’s SSL Monitor