How To Install SSL Certificate on Apache for CentOS 7

Install SSL Certificate on Apache

1- Copy/paste the Certificate files into your server.

Download your SSL Certificate file from your Provider, then paste them into your server’s directory where you will maintain your certificate and key files. Make them possible to read uniquely by root.

2. Install Mod SSL

To install mod_ssl you can check out our installation guide here.

3. Set Up the Certificate

Start by copying your certificate file in /etc/ssl/private

$ mkdir -p /etc/ssl/private
$ chmod 700 /etc/ssl/private

Next is setting up the virtual hosts to showcase the new certificate.

$ sudo vi /etc/httpd/conf.d/ssl.conf
<VirtualHost *:443>
DocumentRoot /var/www/html
ServerName www.example.com
SSLEngine on
SSLCertificateFile /etc/ssl/private/certificate.crt
SSLCertificateKeyFile /etc/ssl/private/private.key
</VirtualHost>

After these edits are completed, save and close the file.

Adjust the file names for them to go with your certificate files:

  • SSLCertificateFile” is supposed to be your certificate file (e.g., your_domain_name.crt).
  • SSLCertificateKeyFile” is supposed to be the key file generated when you made the CSR.

4. Redirect to HTTPS

To redirect traffic to become SSL encrypted, go ahead and open a file ending in .conf in the /etc/httpd/conf.d directory:

$ sudo vi /etc/httpd/conf/httpd.conf
<VirtualHost *:80>
        ServerName www.example.com
        Redirect "/" "https://www.example.com/"
</VirtualHost>

Once completed, save and close the file.

5. Verify the config of your Apache before  you restart.

$ apachectl configtest

Restart Apache.

$ systemctl restart httpd

You are now ready to use the SSL certificate along with your Apache-SSL server.

Check out our SSL certificates offers, you can get cheap SSL from all known SSL providers.

LEAVE A COMMENT