Apache2 SSL configuration on Ubuntu/Debian

Posted by Sim at Jul 24, 2008 06:02 PM |
Filed under: ,

This took way too long for me to figure out so I am creating my own HowTo.

All the HowTos for doing this refer to some script that doesn't exist.  Here is what I did:

apt-get install apache2 ssl-cert
mkdir /etc/apache2/ssl
/usr/sbin/make-ssl-cert /usr/share/ssl-cert/ssleay.cnf  /etc/apache2/ssl/apache.pem
# Answer questions...
cd /etc/apach2/sites-available
cp default ssl
emacs ssl
#
# Add at least:
# NameVirtualHost *:443
# <VirtualHost *:443>
# ...
# SSLEngine On
# SSLCertificateFile /etc/apache2/ssl/apache.pem
#
a2ensite ssl
/etc/init.d/apache2 restart

The other things I needed to do was to split the certificate file into separate cert and key files and als to create the soft link between the sites-enabled and sites-available.

 

Second way of doing it:

setup

   1. sudo apt-get install apache2
   2. sudo apt-get install openssl
   3. sudo apt-get install ssl-cert

create ssl certificate:
sudo make-ssl-cert /usr/share/ssl-cert/ssleay.cnf /etc/ssl/private/localhost.pem

switch to apache sites configuration:
cd /etc/apache2/sites-available/

bakup the default configuration:
sudo cp default default.backup.date

be sure to listen the port 80 for the default:
sudo sed -i '1,2s/\*/*:80/' default

create the ssl configuration:
sudo cp default ssl

set the ssl port:
sudo sed -i '1,2s/\*:80/*:443/' ssl
sudo sed -i "3a\\\tSSLEngine On\n\tSSLCertificateFile /etc/ssl/private/localhost.pem" ssl

enable ssl:
sudo a2ensite ssl
sudo a2enmod ssl

restart apache2:
sudo /etc/init.d/apache2 restart
Document Actions