Turn on HTTPS with a self-signed SSL certificate

Normally you need to pay money to purchase an SSL certificate. However for a development site, it's handy to be able to generate your own self-signed SSL certificate for testing purposes. You could of course use this technique on a public site too if you like, but browsers will complain to end users that your certificate hasn't been generated by a trusted authority.