Prerequisites
OpenSSL installed and updated (should be installed by default)
apt-get update
apt-get upgrade openssl
Apache will be our HTTPS server. To install it, run the following:
apt-get install apache2
Enable the Apache SSL module
a2enmod ssl
The default Apache website comes with a useful template for enabling SSL, so we will activate the default website now
a2ensite default-ssl
Configure Apache to Use SSL
Edit server configuration file
nano /etc/apache2/sites-enabled/default-ssl.conf
Locate the section that begins with
<VirtualHost _default_:443>.
Add a line with your server name directy below the ServerAdmin email line. This can be your domain name or IP address:
ServerAdmin webmaster@localhost
ServerName example.com:443
Find the following two lines, and update the paths to match the locations of the certificate and key. If you purchased a certificate or generated your certificate elsewhere, make sure the paths here match the actual locations of your certificate and key:
SSLCertificateFile /etc/apache2/ssl/apache.crt
SSLCertificateKeyFile /etc/apache2/ssl/apache.key
Restart Apache to put these changes into effect
service apache2 restart