Apache Configuration Steps to Enable HTTPS

Now we will configure Apache server to run as localhost.apple.com with self-signed certificate SSL certificate so it can accept https traffic.

The below instructions were tested on Mac OS Yosemite.

1) Add an entry to /etc/hosts for localhost.apple.com localhost.apple.com

2) Generate a host key

When creating an SSL key please set DN as: localhost.apple.com
Leave the pass phrase empty

sudo mkdir /private/etc/apache2/ssl

cd /private/etc/apache2/ssl

sudo ssh-keygen -f server.key

3) Generate a certificate request file

sudo openssl req -new -key server.key -out request.csr

4) Create the SSL certificate

sudo openssl x509 -req -days 999 -in request.csr -signkey server.key -out server.crt

Configure Apache

1) Create a backup of:

/private/etc/apache2/httpd.conf (or /etc/apache2/httpd.conf)

(The above should be the same file)

2) Edit /etc/apache2/httpd.conf

2.1) Update server name (look for Server Name in httpd.conf)

ServerName localhost.apple.com:80

2.2) Enable ssl and shmcb apache modes (uncomment LoadModule in the httpd.conf file)

LoadModule ssl_module libexec/apache2/mod_ssl.so

LoadModule socache_shmcb_module libexec/apache2/mod_socache_shmcb.so

2.2) Load certificates (uncomment or add the Include):

Include /private/etc/apache2/extra/httpd-ssl.conf

2.3) Edit /private/etc/apache2/extra/httpd-ssl.conf

(uncomment or add certificate entries as follows)

SSLCertificateFile “/private/etc/apache2/ssl/server.crt”

SSLCertificateKeyFile “/private/etc/apache2/ssl/server.key”

2.4) Check the httpd.config and restart Apache

sudo apachectl configtest

sudo apachectl restart

2.5) Check if https works

Enable Proxy Apache Mode

© 2017 Goose Workshop Suffusion theme by Sayontan Sinha