Create Self-Signed Certificates on Apache for CentOS

Install Mod SSL:
yum install mod_ssl

We need to create a new directory where we will store the server key and certificate:
mkdir /etc/httpd/ssl

Create a Self Signed Certificate:
openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/httpd/ssl/apache.key -out /etc/httpd/ssl/apache.crt

Open up the SSL config file:
nano /etc/httpd/conf.d/ssl.conf

Find the section that begins with and make some quick changes.

Uncomment the DocumentRoot and ServerName line (it should be the same as the common name on the certificate):


Find the following three lines, and make sure that they match the extensions below:

SSLEngine on
SSLCertificateFile /etc/httpd/ssl/apache.crt
SSLCertificateKeyFile /etc/httpd/ssl/apache.key

You are done. Save and Restarting the Apache server.

/etc/init.d/httpd restart

Done. In your browser, type to view the new certificate.