Return to Snippet

Revision: 21176
at December 6, 2009 00:18 by benjaminpearson


Initial Code
Open apache config (textmate has been used, but you can replace "mate" with "open -a TextEdit")
  mate /etc/apache2/httpd.conf 

Find "Virtual Hosts". Add and uncomment the two lines below respectively
  # Virtual hosts
  NameVirtualHost *:80
  Include /private/etc/apache2/extra/httpd-vhosts.conf

Edit this file
  mate /private/etc/apache2/extra/httpd-vhosts.conf
By adding this for each website (ensure the trailing "/" in the Directory tag path
  <Directory "/absolute/path/to/uniquename/website/files/">
    Options Indexes MultiViews FollowSymLinks
    AllowOverride All
    Order allow,deny
    Allow from all
  </Directory>
  <VirtualHost *:80>
    ServerName "unqiuename"
    DocumentRoot "/absolute/path/to/uniquename/website/files"
  </VirtualHost>

Edit this file
  mate /etc/hosts
At the bottom add foreach site
  127.0.0.1 unqiuename

Restart apache
  sudo httpd -k restart

You may also need to flush dns cache, commads for Leopard and before 10.5.1 respectively
  dscacheutil -flushcache
  lookupd -flushcache

Now visit in your browser
  http://unqiuename/

Initial URL

                                

Initial Description
Instructions for enabling multiple virtual hosts on Mac OSX. Based on default Apple Apache install. If you don't want to be manually changing these files, checkout the very slick GUI application - VirtualHostX (http://clickontyler.com/virtualhostx/)

Initial Title
Multiple Virtual Hosts on Mac

Initial Tags
mac

Initial Language
Apache