Skip to content

Instantly share code, notes, and snippets.

@offsky
Last active August 29, 2015 14:04
Show Gist options
  • Save offsky/1d1701d24b936435a52e to your computer and use it in GitHub Desktop.
Save offsky/1d1701d24b936435a52e to your computer and use it in GitHub Desktop.
vhost setup on Mac
From http://coolestguidesontheplanet.com/set-virtual-hosts-apache-mac-osx-10-9-mavericks-osx-10-8-mountain-lion/
sudo nano /etc/apache2/httpd.conf
Uncomment
Include /private/etc/apache2/extra/httpd-vhosts.conf
sudo nano /etc/apache2/extra/httpd-vhosts.conf
Make your changes and save
<VirtualHost *:80>
ServerAdmin webmaster@dummy-host2.example.com
DocumentRoot "/Users/offsky/Sites/whatever"
ServerName www.example.com
ErrorLog "/private/var/log/apache2/www.example.com-error_log"
CustomLog "/private/var/log/apache2/www.example.com-access_log" common
</VirtualHost>
sudo nano /etc/hosts
Add
127.0.0.1 sub.domain.com
sudo apachectl restart
==SSL==
http://webdevstudios.com/2013/05/24/how-to-set-up-ssl-with-osx-mountain-lions-built-in-apache/
http://www.akadia.com/services/ssh_test_certificate.html
sudo nano /etc/apache2/httpd.conf
Uncomment both
LoadModule ssl_module libexec/apache2/mod_ssl.so
Include /private/etc/apache2/extra/httpd-ssl.conf
sudo nano /etc/apache2/extra/httpd-vhosts.conf
Make your changes and save
NameVirtualHost *:443
<VirtualHost *:443>
SSLEngine on
SSLProtocol all -SSLv2
SSLCipherSuite HIGH:MEDIUM:!aNULL:!MD5
SSLCertificateFile "/private/etc/apache2/ssl/server.crt"
SSLCertificateKeyFile "/private/etc/apache2/ssl/server.key"
ServerAdmin webmaster@dummy-host2.example.com
DocumentRoot "/Users/offsky/Sites/whatever"
ServerName www.example.com
ErrorLog "/private/var/log/apache2/www.example.com-error_log"
CustomLog "/private/var/log/apache2/www.example.com-access_log" common
</VirtualHost>
Create SSL certificate
openssl genrsa -des3 -out server.key 1024
openssl req -new -key server.key -out server.csr
cp server.key server.key.org
openssl rsa -in server.key.org -out server.key
openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
sudo apachectl configtest
sudo apachectl restart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment