Here’s an easy guide to add SSL certificate on your Ubuntu server with Apache2
It’s gotten to the point where everyone needs to get their website encrypted, no matter how big or small a website is. To do so, you need to install an SSL/TLS certificate. Here comes the problem. A good percentage of the website administrators are from the non-technical background who may not have heard about SSL, let alone installing it. That’s where we come into the picture. We try to help you out with your SSL/TLS queries. And this time, we’ve come up with a blog that will let you install an SSL certificate on your Ubuntu server with Apache2.
Let’s get straight to the crux of the matter without wasting much time. We have assumed that you have gone through the CSR generation and ordering process. But if you haven’t, use our CSR Generation Guide to easily generate a CSR and purchase an SSL certificate before installing your SSL certificate on Ubuntu.
Step 1: Download and Copy your certificate files
First, download your intermediate and certificate files. Now copy them, along with your private key, to your server directory where you intend to keep your certificate and key files. Don’t forget to make them readable by root only.
Step 2: Find the Apache config file
Most of the times, the configuration file of Ubuntu with Apache2 can be accessed at:
/etc/apache2/sites-enabled/your_site_name
If you’re not able to find it, run the below command.
sudo a2ensite your_site_name
Now that you’ve found the file you’re looking for, open it with a text editor (such as Notepad) and find <VirtualHost> block consisting of Apache setting.
Step 3: Find which SSL block you need to configure
Now here, you have got two options. Do you want your website to be accessible through secure HTTPS as well as insecure HTTP? Or, you want to enable HTTPS only? If you want the former, you’ll need to create two separate files in /etc/apache2/sites-enabled/. One will be used for port 80 (HTTP) and one for port 443 (HTTPS). If the latter is your choice, create only a single file.
Step 5: Configure the <VirtualHost> block
Here’s an example of a configured virtual host file:
<VirtualHost 192.168.0.1:443>
DocumentRoot /var/www/
SSLEngine on
SSLCertificateFile /path/to/your_domain_name.crt
SSLCertificateKeyFile /path/to/your_private.key
SSLCertificateChainFile /path/to/DigiCertCA.crt
</VirtualHost>
To make it clear, this is what the lines of the above command represent:
SSLCertificateFile – Your main certificate file
SSLCertificateKeyFile – Your private key
SSLCertificateChainFile – Your intermediate certificate file
Step 6: Restart your server
Voila! You have successfully installed an SSL certificate on Ubuntu using Apache2.