I'm trying to set up Apache which includes putting this path into httpd-vhosts.conf file:

DocumentRoot "/usr/local/var/www"

but I can't find the folder. The only path that seems to resemble the folder is /private/var but it doesn't contain a www folder/file. Where is it located?

  • 2
    You are free to set DocumentRoot to whatever value you want - the only restriction is that the user that runs the Apache web server must be able to read the directory contents. If you don't want to create /usr/local/var/www, use a different directory, for example /Library/WebServer/Documents (this is the directory the Apache web server included with macOS uses, see /etc/apache2/httpd.conf).
    – jaume
    Jul 9, 2022 at 12:23
  • 1
    Many guides for Apache on macOS do prefer ~/Sites and /Library/WebServer/Documents so use caution if you prefer /usr/local and everyone needs to watch for Previous Items when updates run. Avoiding [ACL permissions](apple.stackexchange.com/a/365364/5472 ) might be a good reason for local based storage and posix permissions.
    – bmike
    Jul 10, 2022 at 11:43

1 Answer 1


As an admin user, run

sudo mkdir -p /usr/local/var/www
sudo chown _www:_www /usr/local/var/www

User/group _www is the default setting in /etc/apache2/httpd.conf. If you have a different user/group for your webserver, you need to adapt the second command accordingly.

To make this work with whatever path is defined in httpd.conf, run

docroot=$(sed -E -n '/^DocumentRoot/{
}' /path/to/httpd.conf)
sudo mkdir -p "$docroot"
sudo chown _www:_www "$docroot"

(the first four lines are one command, but macOS sed expects function lists to be separated by newlines.)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .