How to Install SSL Certificate on Ubuntu 16 and Apache Server | Cloud Server Tutorial

Submitted by techyboy on Fri, 10/20/2017 - 20:34
install ssl certificate on ubuntu linux operating system

It is a know fact that google gives extra value to those websites that use SSL certificates. Browsers show a Green Pad Lock Icon next to address bar to indicate that the information exchanged with the website is secure. Though SSL slows down your site little bit, it is worth upgrading your site from HTTP to HTTPS. Along with Cloud CMS apps like Wordpress, Drupal and Joomla, Ubuntu Operating System is offered. We show you how to install SSL certificates on Ubuntu 16 OS, a variation of Linux Distribution.

Also Read Choosing a Bluehost Devcloud Cloud Server & Managing Your Cloud Apps Drupal, Wordpress, Joomla Like a Pro | Cloud Hosting Tutorial

SSL referes to Secure Socket Layer that safely encrypts all bits and bytes exchanged between a Server and a Client. Data encrypted on one end will be decrypted on the other end to process the data. HTTPS ( Hyper Text Transfer Protocol - Secure ) takes care of negotiations between client and server.

 

We assume that you have readymade SSL Certicates on hand. If not, you can follow the tutorial to generate SSL certificates on your own.

 

Steps to Install SSL Certficate on Ubuntu 16 Apache Server

Download the generated SSL Certificates from say GoDaddy or any other SSL Provider. Usually you get 2 or more .CRT Certificate files. You need to combine all the .CRT files into one single SSL Certificate File to avoid SSL Certificate Chaining Errors. Among all .crt files, one file will be the name "bundle.crt". Each .crt file contains a big random code. You can open .crt file using a simple notepad file.

Combining SSL Certificate Files To Avoid Certificate Chain Error

Create a blank .crt file say fullssl.crt using Notepad++ like editing tool. Copy and paste the contents of .crt files other than Bundle.crt into fullssl.crt. At last, copy and paste bundle crt code also into fullssl.crt. Now you have one fullssl.crt file and a Private key file yourdomain.key. Private key will be generated using openssl command which we have shown above in generate SSL certificates tutorial.

Installing SSL 

1. Go to etc/apache2/sites-available folder.

etc

------apache2

-----------------sites-available

--------------------------- default-ssl.conf

--------------------------- drupal.conf

 

2. Copy fullssl.crt and yourdomain.key files to etc/ssl folder

etc

---- ssl

---------- fullssl.crt

---------- yourdomain.key

 

3. Open default-ssl.conf with notepad++ and write the location of SSL certifiates and Key file.

    <VirtualHost _default_:443>
        
        ServerName yourdomain.com
        ServerAlias www.yourdomain.com
        
        SSLEngine on

        SSLCertificateFile    /etc/ssl/fullssl.crt
        SSLCertificateKeyFile    /etc/ssl/yourdomain.key

        SSLCertificateChainFile /etc/ssl/fullssl.crt

 

......

...

    </VirtualHost>

 

4. Now open the console and type the following commands.

console> sudo a2enmod ssl

console> sudo a2ensite default-ssl

Restart your apache server to make your changes live.

console> sudo /etc/init.d/apache2 restart

 

5. Now open your browser and type https://www.yourdomain.com. You should get a green padlock indicating that the connection is secured with SSL certificates.

 

6. If user types a https, he will be taken to a secured version of your site. By default no user types either http or https. Simply he types yourdomain.com or www.yourdomain.com. Your pending work is to redirect all http requests of your site to https. Even search engines like your https version pages for indexing purpose.

Redirecting all http requests to https:

Open your CONF file or any other Virtual Host for port 80. Change your domain name to what ever you want.

<Virtualhost *:80>

    RewriteEngine On
    RewriteCond %{HTTPS} !=on
    RewriteRule ^/(.*) https://www.yourdomain.com/$1 [R,L]

.....

...

</VirtualHost>

 

This completes configuring of SSL Certificates on Ubuntu 16 Apache Server. Hope you enjoyed the tutorial. Drop your comments below.

Add new comment

Next Article