Generate a Self-Signed Certificate for Apache in Linux

By | 2013/06/24

For non-production or personal servers, a self-signed certificate is sufficient. It’s easy to generate this cert in Linux. I’ll show you how!

This will generate a self-signed SSL certificate:

$ openssl req -new -newkey rsa:2048 -x509 -days 1095 -nodes -out server.crt -keyout server.key

When generating the certificate, the critical portion is the CommonName. Make this the fqdn of your server!

To implement this self-signed cert, use this designation in Apache:

SSLCertificateFile /path/to/server.crt
SSLCertificateKeyFile /path/to/server.key