Quick steps to enable SSL for your Apache website (Debian squeeze)

Make your site use HTTPS (and force it)

This article assumes you have basic Linux knowledge and have installed Apache2.

Enable SSL

sudo a2enmod ssl
sudo service apache2 restart

Make a directory for the keys

sudo mkdir /etc/apache2/ssl

Create .key and .crt (good for 3 years)

sudo openssl req -x509 -nodes -days 1095 -newkey rsa:2048 -keyout /etc/apache2/ssl/apache.key -out /etc/apache2/ssl/apache.crt

Edit your site (in sites-available)

<VirtualHost *:80>
ServerName your.site.com
Redirect permanent / https://your.site.com/

<VirtualHost *:443>
ServerName your.site.com
# Ye olde normal content
SSLEngine on
SSLCertificateFile /etc/apache2/ssl/apache.crt
SSLCertificateKeyFile /etc/apache2/ssl/apache.key

Restart apache2 again:

sudo service apache2 restart

Bonus: Make a directory on your site require authentication

<Directory /path/to/your/passworded/dir>

# Other options here

AuthType Basic
AuthName "password please"
AuthBasicProvider file
AuthUserFile /home/username/passwordfile
Require valid-user


You’ll want to create the authorization info in the passwordfile:

htpasswd -c /home/username/passwordfile username

After that you can add more users by omitting -c, otherwise it’ll overwrite the file.


Don’t forget to allow/forward ports 80 and 443




About a1100320

IT student, musician, gamer. Beep boop.
This entry was posted in Uncategorized. Bookmark the permalink.

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