Step One—Activate the SSL Module
Follow up by restarting Apache.
service apache2 restart
Step Two—Create a New Directory
Step Three—Create a Self Signed SSL Certificate
When we request a new certificate, we can specify how long the certificate should remain valid by changing the 365 to the number of days we prefer. As it stands this certificate will expire after one year.
openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/apache2/ssl/apache.key -out /etc/apache2/ssl/apache.crt
This command will prompt terminal to display a lists of fields that need to be filled in.
The most important line is “Common Name”. Enter your official domain name here or, if you don’t have one yet, your site’s IP address.
You are about to be asked to enter information that will be incorporated into your certificate request. What you are about to enter is what is called a Distinguished Name or a DN. There are quite a few fields but you can leave some blank For some fields there will be a default value, If you enter '.', the field will be left blank. ----- Country Name (2 letter code) [AU]:US State or Province Name (full name) [Some-State]:New York Locality Name (eg, city) :NYC Organization Name (eg, company) [Internet Widgits Pty Ltd]:Awesome Inc Organizational Unit Name (eg, section) :Dept of Merriment Common Name (e.g. server FQDN or YOUR name) :example.com Email Address :email@example.com
Step Four—Set Up the Certificate
Change the port on the virtual host to 443, the default SSL port:
<VirtualHost *:443> ServerName example.com
Replace example.com with your DNS approved domain name or server IP address (it should be the same as the common name on the certificate).
Add in the following three lines to the end of your virtual host configuration, and make sure that they match the extensions below:
SSLEngine on SSLCertificateFile /etc/apache2/ssl/apache.crt SSLCertificateKeyFile /etc/apache2/ssl/apache.key
Save and Exit out of the file.
Step Five—Activate the New Virtual Host
a2ensite default service apache2 reload From me: After your apache2 reload, maybe any error message, like this : "_default_ VirtualHost overlap on port 443, the first has precedence" .. Solutions:
after installing ssl on ubuntu lucid, add this line
and restart apache2.