Configure Apache SSL for https on Mac OS
1. Create ssl directory
[code language=”shell”]
mkdir /etc/apache2/ssl
cd /etc/apache2/ssl
[/code]
2. Create server key, just press enter when asked for password.
[code language=”shell”]
sudo ssh-keygen -f server.key
[/code]
3. Create certificate request file. Enter info or leave blank when asked various questions.
[code language=”shell”]
sudo openssl req -new -key server.key -out request.csr
[/code]
4. Create SSL certificate file from the request file.
[code language=”shell”]
sudo openssl x509 -req -days 99999 -in request.csr -signkey server.key -out server.crt
[/code]
5. Open /etc/apache2/httpd.conf, make sure you have these 3 lines in it. If not, add them. If there is but with # sign at the beginning, remove the # sign.
[code language=”shell”]
Listen 443
LoadModule ssl_module libexec/apache2/mod_ssl.so
Include /private/etc/apache2/extra/httpd-ssl.conf
[/code]
6. Open /etc/apache2/extra/httpd-ssl.conf search for lines with SSLCertificateFile and SSLCertificateKeyFile, update them to the below
[code language=”shell”]
SSLCertificateFile "/etc/apache2/ssl/server.crt"
SSLCertificateKeyFile "/etc/apache2/ssl/server.key"
[/code]
7. Configure vhosts to enable https 443, open /etc/apache2/extra/httpd-vhosts.conf and the below to it. Replace the value for ServerName, DocumentRoot and Directory path to yours.
[code language=”shell”]
<VirtualHost 127.0.0.1:80>
ServerName test.com
DocumentRoot "/Users/shunter/Sites/test"
<Directory "/Users/shunter/Sites/test">
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost 127.0.0.1:443>
ServerName test.com
DocumentRoot "/Users/shunter/Sites/test"
SSLEngine on
SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL
SSLCertificateFile /etc/apache2/ssl/server.crt
SSLCertificateKeyFile /etc/apache2/ssl/server.key
<Directory "/Users/shunter/Sites/test">
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
[/code]
8. Edit host file for your sever name, open /etc/hosts and add this line to it
[code language=”shell”]
127.0.0.1 test.com
[/code]
9. Restart apache
[code language=”shell”]
sudo /usr/sbin/apachectl restart
[/code]
10. Assume you have a index page in /Users/shunter/Sites/test, test it by going to https://test.com
An interesting note: A file created or modified in /etc/apache2/ will reflected in /private/etc/apache2/
Search within Codexpedia

Search the entire web
