Install & Enable HTTPS on Apache Server

Trustico-DigiCert

Install & Enable HTTPS on Apache Server

First of all, you need to have a website that can run under http. This tutorial is about Apache2, and other servers may have similar settings.

  1. Get a free SSL certificate.
    Now Let’s Encrypt offers free SSL certificate service. So we need to register an account. Then, after landing you can apply for a free SSL certificate. Finally save the requested certificate locally.
  2. Configure the Apache2 environment
    This will automatically install the SSL plugins required for Apache2.
    sudo a2enmod ssl
    
    sudo a2ensite default-ssl

    Create a default SSL site that will be in /etc/apache2/sites-enabled/ to generate a configuration file.

    In /etc/apache2/creating two folders

    cd /etc/apache2
    
    sudo mkdir ssl.key
    sudo mkdir ssl.crt

    Upload *.crt to ssl.crt folder, upload *.ssl to ssl.key folder.
    Next, we start the configuration default-ssl.conf file

    sudo vim /etc/apache2/sites-enabled/default-ssl.conf

    In which the following attributes are changed

    SSLCertificateFile     /etc/apache2/ssl.crt/2_***.crt
    
    SSLCertificateKeyFile /etc/apache2/ssl.key/3_***.key
    SSLCertificateChainFile /etc/apache2/ssl.crt/1_***.crt

    After the change is successful, restart the Apache2 service

    sudo service apache2 restart

    Finally, try to access https://YourDomain

  3. Enable https by default
    On .htaccess file, add
    RewriteEngine On
    
    RewriteBase /
    RewriteCond %{SERVER_PORT} !^443$
    RewriteRule ^(.*)$ https://YourDomain/ [L]

    After the creation is complete, change /etc/apache2/apache2.conf

    AllowOverride All
  4. Enjoy