SSL Certificates with Apache 2 on CentOS

Generate a Self-Signed Certificate

At the shell prompt, issue the following commands to install SSL for Apache and generate a certificate:

yum install mod_ssl
mkdir /etc/httpd/ssl
openssl req -new -x509 -sha256 -days 365 -nodes -out /etc/httpd/ssl/httpd.pem -keyout /etc/httpd/ssl/httpd.key

Configure Apache to use the Self-Signed Certificate

NameVirtualHost *:443

SSLEngine On
SSLCertificateFile /etc/httpd/ssl/httpd.pem
SSLCertificateKeyFile /etc/httpd/ssl/httpd.key
DocumentRoot /srv/www/
ErrorLog /srv/www/
CustomLog /srv/www/ combined

Restart Apache:

service httpd restart

Leave a Reply

Your email address will not be published. Required fields are marked *