SSL Certificate Installation in Ubuntu Server with Apache2
Ubuntu Server with Apache2 SSL Certificate Installation
These instructions were created using Ubuntu server 12.x. Additional help is available at: https://help.ubuntu.com/12.04/serverguide/httpd.html.
Copy the Certificate files to your server.
Download your Intermediate (DigiCertCA.crt) and Primary Certificate (your_domain_name.crt) files from your DigiCert Management Console, 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.
Ubuntu's Apache configuration file for your ssl site is typically found in /etc/apache2/sites-enabled/your_site_name. If it is not found in the 'sites-enabled' folder, you would need to run the command sudo a2ensite your_site_name.
If you open the file with a text editor, you should be able to find
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 two separate files in /etc/apache2/sites-enabled/. One will be for port 80 and the other file for port 443. 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 configured for the SSL configuration and they may be spread out throughout the file:
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 (it is apache2ctl on some systems):
You can use apachectl commands to stop and start Apache with SSL support:
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
andtags that enclose your SSL configuration.
Configuration and Useful Commands
Required for SSL certificates to be used:
Enable SSL Module
'default-ssl' can be replaced by the real site name you set up in /etc/apache2/sites-available/
Once the site listed in the command above is enabled with that command, the site will appear in /etc/apache2/sites-enabled.
Apply SSL Module to Site
Once the a2enmod ssl command has been run, you can edit the ssl.conf file in /etc/apache2/mods-enabled.
If the a2enmod command has not been run yet, you can preconfigure the ssl.conf file in /etc/apache2/mods-available.