Proper way to set file permissions

For each parent directory leading to your web root (e.g. ~/my~/my/web~/my/web/root):

  • chmod go-rwx DIR (nobody other than owner can access content)
  • chmod go+x DIR (to allow “users” including _www to “enter” the dir)
  • sudo chgrp -R _www ~/my/web/root (all web content is now group _www)
  • chmod -R go-rwx ~/my/web/root (nobody other than owner can access web content)
  • chmod -R g+rx ~/my/web/root (all web content is now readable/executable/enterable by _www)

 

Taken from http://stackoverflow.com/questions/2001881/correct-owner-group-permissions-for-apache-2-site-files-folders-under-mac-os-x

Adding vhosts in Apache

On a native install on Mac, to add a vhost:

If you haven’t done this one time step, do this first to enable vhosts:

Then uncomment the line that includes the vhost config file:

 

 

Next add an entry to the hosts file

To add dev.localhost, do this:

Next, do this:

Then add a new entry for dev.localhost:
(This is for Apache 2.2)

(This is for Apache 2.4)

[Note the subtle differences between Apache 2.2, and 2.4. More info here ]

 

Also, be sure to remove the two dummy-host entries if they are there. Otherwise, you’ll get a warning about them not being found when you restart apache.