How to install SSL certificate in apache in Linux


Apache Server SSL Certificate Installation

 If you are installing an Extended Validation SSL Certificate, use our Apache EV SSL Certificate Installation Instructions. If you are installing any other certificate, follow the instructions below.

 Copy the Certificate files to your server.

Download your Intermediate (DigiCertCA.crt) and Primary Certificate (your_domain_name.crt) files from your Customer Area, then copy them to the directory on your server where you will keep your certificate and key files. Make them readable by root only. 

 Find the Apache config file to edit.

The location and name of this file can vary from server to server — Especially if you use a special interface to manage your server configuration. Apache configuration files are typically found in /etc/httpd.

The main configuration file is usually named httpd.conf. In some cases the <VirtualHost> blocks will be at the bottom of this httpd.conf file. Sometimes you will find the <VirtualHost> blocks in their own files under a directory like /etc/httpd/vhosts.d/ or /etc/httpd/sites/ or in a file called ssl.conf.

If you open the file with a text editor, you should be able to find <VirtualHost> blocks which contain Apache settings. 

Identify the SSL <VirtualHost> block to configure.

If you need your site to be accessible through both secure (https) and non-secure (http) connections, you will need a virtual host for each type of connection. Make a copy of the existing non-secure virtual host and configure it for SSL as described in step 4.
If you only need your site to be accessed securely, configure the existing virtual host for SSL as described in step 4. 

Configure the <VirtualHost> block for the SSL-enabled site.

Below is a very simple example of a virtual host configured for SSL. The parts listed in bold are the parts that must be added for SSL configuration:

<VirtualHost 192.168.0.1:443>

DocumentRoot /var/www/html2

ServerName http://www.yourdomain.com

SSLEngine on

SSLCertificateFile /path/to/your_domain_name.crt

SSLCertificateKeyFile /path/to/your_private.key

SSLCertificateChainFile /path/to/DigiCertCA.crt

</VirtualHost>

Adjust the file names to match your certificate files:

  • SSLCertificateFile should be your DigiCert certificate file (eg. your_domain_name.crt).
  • SSLCertificateKeyFile should be the key file generated when you created the CSR.
  • SSLCertificateChainFile should be the DigiCert intermediate certificate file (DigiCertCA.crt) If the SSLCertificateChainFile directive does not work, try using the SSLCACertificateFile directive instead.

Test your Apache config before restarting.

It is always best to check your Apache config files for any errors before restarting, because Apache will not start again if your config files have syntax errors. Run the following command:

[root@server~]# apachectl configtest

Restart Apache.

You can use apachectl commands to stop and start Apache with SSL support:

[root@server~]#apachectl stop

[root@server~]#apachectl start 

Note: If Apache does not start with SSL support, try using “apachectl startssl” instead of “apachectl start”. If SSL support only loads with “apachectl  startssl” we recommend you adjust the apache startup configuration to include SSL support in the regular “apachectl start” command.

Otherwise your server may require that you manually restart Apache using “apachectl startssl” in the event of a server reboot. This usually involves removing the <IfDefine SSL> and </IfDefine> tags that enclose your SSL configuration.

Check whether the SSL key and cert are maching

============================================
openssl x509 -noout -modulus -in certificate.crt | openssl md5 openssl rsa -noout -modulus -in keyfile.crt |openssl md

About Alex Hunt

Hi All I am Manish Kumar Jha aka Alex Hunt. I am currently working in VMware Software India Pvt Ltd as Operations System Engineer (vCloud Air Operations). I have around 5 Years of IT experience and have exposure on VMware vSphere, vCloud Director, RHEL and modern data center technologies like Cisco UCS and Cisco Nexus 1000v and NSX. If you find any post informational to you please press like and share it across social media and leave your comments if you want to discuss further on any post. Disclaimer: All the information on this website is published in good faith and for general information purpose only. I don’t make any warranties about the completeness, reliability and accuracy of this information. Any action you take upon the information you find on this blog is strictly at your own risk. The Views and opinions published on this blog are my own and not the opinions of my employer or any of the vendors of the product discussed.
This entry was posted in Apache. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s