Knowledgebase: Application
How do I enable SSL support in Apache?
Posted by Sinan Esen on 18 May 2015 12:20 PM


This article applies to VPSs with Apache2.


To enable SSL support:

  • Run the following command from SSH:
a2enmod ssl
  • Once done, you will need to restart Apache by running the following command:
/etc/init.d/apache2 restart

NB: Apache should restart without any errors.

 

Configuring SSL Hosts:

  • You need to upload your SSL certificates (certificate and the key file) in a particular directory
    For example:
    • /etc/apache2/ssl

 

  • You now need to add your domain specific settings,
    They are kept in /etc/apache2/sites-enabled/000-default

 

  • You can add the following configuration for example:

NameVirtualHost *:443
NameVirtualHost *:80

<VirtualHost *:80>
     VirtualDocumentRoot /var/www/%0
     DocumentRoot /var/www/www.mydomain.co.nz
     ErrorLog /var/log/apache2/error.log
     CustomLog /var/log/apache2/access.log combined
</VirtualHost>

<IfModule mod_ssl.c>
     <VirtualHost *:443>
          VirtualDocumentRoot /var/www/%0
          DocumentRoot /var/www/www.mydomain.co.nz
          ErrorLog /var/log/apache2/error.log
          CustomLog /var/log/apache2/access.log combined
          SSLEngine on
          SSLCertificateFile /etc/apache2/ssl/domainname.crt
          SSLCertificateKeyFile /etc/apache2/ssl/domainname.key
     </VirtualHost>
</IfModule>

  • Once this is done, you have to restart again to finish the process

 

 

(0 vote(s))
Helpful
Not helpful