Skip to content

Instantly share code, notes, and snippets.

@Airr
Created March 30, 2013 06:02
Show Gist options
  • Save Airr/5275581 to your computer and use it in GitHub Desktop.
Save Airr/5275581 to your computer and use it in GitHub Desktop.
Set up ssl with cheapssl and apache2 on ubuntu 12.04
ssl with cheapssl and apache2
-Purchase a ssl certificate
sudo a2enmod ssl
sudo /etc/init.d/apache2 restart
sudo mkdir /etc/apache2/ssl
cd /etc/apache2/ssl
******EDIT THE LINE BELOW WITH DOMAIN******
sudo openssl req -new -nodes -newkey rsa:2048 -keyout MYDOMAIN.key -out MYDOMAIN.csr
-Answer the prompts, 'Common Name' must be the domain name
-------
Country Name (2 letter code) [AU]:US
State or Province Name (full name) [Some-State]:NY
Locality Name (eg, city) []:New York
Organization Name (eg, company) [Internet Widgits Pty Ltd]:Company
Organizational Unit Name (eg, section) []:Web Dev
Common Name (eg, YOUR name) []:MYDOMAIN.COM
Email Address []:support@mydomain.com
Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []: (can't leave these blank)
An optional company name []: (can't leave these blank)
-------
cat mydomain.csr
-Paste the contents (including beginning and end comments) into the cheapssl web form (apache2 for type)
-Fill out remaining info on cheapssl
-You will be sent an email (check spam folder, one ended up in there) click on the link and enter the validation code in the email.
-After validaion, you will be sent 3 files
mydomain_com.crt
AddTrustExternalCARoot.crt
PositiveSSLCA2.crt
-Open AddTrustExternalCARoot.crt and PositiveSSLCA2.crt in notepad and copy and paste them both into one file called:
mydomain_com.ca-bundle
-Place mydomain_com.crt and mydomain_com.ca-bundle in the /etc/apache2/ssl directory.
-Add this to the vhost (or default-ssl for a single domain)
<VirtualHost *:443>
ServerName mydomain.com
ServerAlias www.mydomain.com
ServerAdmin support@mydomain.com
DocumentRoot /var/www/mydomain.com
SSLEngine on
SSLCertificateFile /etc/apache2/ssl/mydomain_com.crt
SSLCertificateKeyFile /etc/apache2/ssl/mydomain.key
SSLCertificateChainFile /etc/apache2/ssl/mydomain_com.ca-bundle
</VirtualHost>
-Save and restart apache again
sudo /etc/init.d/apache2 restart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment