How to setup SSL on Apache

Setting up SSL on your Apache server is a pretty good idea even if you are only just hosting your own website with a CMS like drupal. With SSL enabled, you can now securely login, make updates, and post blog entries like me :-). Here is what you have to do:

Step 1. Generate an SSL certificate. All you really need is a self signed certificate unless of course you are doing something for work. The command below should do the trick. Just fill out the fields that it prompts you for.
apache2-ssl-certificate

Step 2. Enable the SSL module. The following command should do it:
a2enmod ssl

Step 3. Configure SSL in your virtual host. You will need to add these two lines to your virtual host configuration.
SSLEngine on
SSLCertificateFile /path/to/your.pem

Here is an example of what a virtual host configuration using SSL:
NameVirtualHost *:443
NameVirtualHost *:80
<VirtualHost *:80>
        ServerName your.domain.com
        DocumentRoot /var/www/
        ErrorLog /var/log/apache2/error.log
        CustomLog /var/log/apache2/access.log combined
</VirtualHost>
<VirtualHost *:443>
        ServerName your.domain.com
        DocumentRoot /var/www/
        ErrorLog /var/log/apache2/error.log
        CustomLog /var/log/apache2/access.log combined
        SSLEngine on
        SSLCertificateFile /path/to/your.pem
</VirtualHost>

  1. verycrispy posted this
Short URL for this post: http://tmblr.co/Zd8FQxE1CNfC