Chris Earls

Maker of Fine Websites

1 note

Setting up SSL on Ubuntu Hardy and Apache

I put together some instructions on setting up SSL on an Ubuntu Hardy server running Apache.

Server Prep

Server needs OpenSSL installed and Apache SSL Mod enabled to work.

sudo apt-get install openssl
sudo a2enmod ssl
sudo /etc/init.d/apache2 reload


Instructions

Generate a private key for the website anywhere on the server you want to (Replace sitename with your website’s name throughout these instructions):

sudo openssl genrsa -out sitename.key 1024

In the same place, generate a CSR file:

openssl req -new -key sitename.key -out sitename.csr

You will be prompted for data about the website. Here’s an example:

Country: US
State: AR
City: Little Rock
Organization: Acme Web
Unit: Webmasterzz (department name, whatever)
Common Name: www.example.com

Give the contents of the .csr file to security authority (Thawte, GoDaddy, whoever). They will send you a certificate (.crt) file.

FTP the certificate to the server. Copy both the certificate and key file to the ssl folders:

sudo cp sitename.com.crt /etc/ssl/certs
sudo cp sitename.key /etc/ssl/private

Add port 443 virtual host information to your existing vhost. Here’s an example (change paths, ip’s, etc. to your website’s information):

<VirtualHost 209.20.94.138:443>
DocumentRoot /home/admin/public_html/sitename
ServerName example.com
ServerAlias www.example.com
SSLEngine on
SSLCertificateFile /etc/ssl/certs/www.example.com.crt
SSLCertificateKeyFile /etc/ssl/private/sitename.key
</VirtualHost>


Restart Apache:

sudo /etc/init.d/apache2 reload


Filed under ssl ubuntu apache

  1. chrisearls posted this