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
ServerAdmin info@mydomain.com
ServerName www.mydomain.com
DocumentRoot /srv/www/mydomain.com/public_html/
ErrorLog /srv/www/mydomain.com/logs/error.log
CustomLog /srv/www/mydomain.com/logs/access.log combined

Restart Apache:


service httpd restart

Leave a Reply

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