Enabling SSL in Apache

Recently I had to do this task twice in the last month at different localhosts, so I’m writing this post as a personal note (all this blog is meant to be a sort of memo book, though).

This mini-guide is heavily based on pradeepchhetri’s answer on stackexchange and this tutorial from 2012, so credit goes to them.

First, create the certificates:
cd /etc/apache2/
sudo openssl genrsa -out localhost.key 1024
sudo openssl req -new -key localhost.key -x509 -out localhost.crt
sudo chmod 600 localhost.*

Then edit /etc/apache2/sites-available/default-ssl and put the important parts:
<VirtualHost *:443>
SSLEngine on
SSLCertificateFile /etc/apache2/localhost.crt
SSLCertificateKeyFile /etc/apache2/localhost.key

Finally activate SSL and reload Apache:
sudo a2enmod ssl
sudo a2ensite default-ssl
sudo service apache2 reload

That’s it!

PS: These tips are for development pruposes. In production you’ll need a chained certificate (aka certificate bundle).


One thought on “Enabling SSL in Apache

  1. Pingback: Enabling SSL in Nginx | Computer Science Tales

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s