Of course you should never use a self signed SSL certificate in production, however this can be useful for testing and development. Consider buying a real certificate.
Simply follow the following steps. I've assumed you are already in the /etc/apache2/ssl/
directory, or you are going to save elsewhere and update the relevant lines below.
And, if not obvious, replace [arbitrary_name]
with your domain or development host name.
openssl genrsa -out [arbitrary_name].key 2048
openssl genrsa -out [arbitrary_name].key 2048
<VirtualHost [arbitrary_name]:443>
ServerName [arbitrary_name]
SSLEngine on
SSLCertificateKeyFile /etc/apache2/ssl/[arbitrary_name].key
SSLCertificateFile /etc/apache2/ssl/[arbitrary_name].cert
SetEnvIf User-Agent ".*MSIE.*" nokeepalive ssl-unclean-shutdown
# ...
</VirtualHost>
Note, you will have to enable SSL by running:
sudo a2enmod ssl