Wednesday, September 9, 2009

Install SSL Support in Apache2

Install Apache2 and PHP5:
Following the following post on installing Apache2 and PHP5:
http://handsonasterisk.blogspot.com/2009/07/install-apache2-and-php5-in-debian-etch.html

Install OpenSSL:
# apt-get install openssl ssl-cert

Generate a certificate:
#openssl req $@ -new -x509 -days 365 -nodes -out /etc/apache2/apache.pem -keyout /etc/apache2/apache.pem

Only need to enter the Common Name, enter '.' for all other fields.

Set Apache2 to listen on 443:
Enter the following entry to the file /etc/apache2/ports.conf
Listen 443

Enable SSL support in Apache2:
# a2enmod ssl
# /etc/init.d/apache2 force-reload

Configure SSL certificate to virtual hosts in Apache2:
You need to edit /etc/apache2/sites-available/default file:

From:
NameVirtualHost *
<virtualhost>
.
.
</virtualhost>

To:
NameVirtualHost *:80
<virtualhost *:80>
.
.
</virtualhost>

NameVirtualHost *:443
<virtualhost *:443>
ServerAdmin webmaster@localhost
SSLEngine on
SSLCertificateFile /etc/apache2/apache.pem
.
.
</virtualhost>

Restart Apache2:
# /etc/init.d/apache2 restart

References:
Install and Configure Apache2 with PHP5 and SSL Support in Debian Etch
http://www.debianadmin.com/install-and-configure-apache2-with-php5-and-ssl-support-in-debian-etch.html