Where apps hide your files
The Apache that ships with macOS reads its settings from /etc/apache2/httpd.conf, a root-owned file in a folder Finder does not show. A Homebrew Apache uses a different file, and mixing the two up is the usual reason edits seem to do nothing.
For the Apache that comes with macOS:
/etc/apache2/httpd.conf
/etc is a link to /private/etc, so you will also see the path written as /private/etc/apache2/httpd.conf. They are the same file. For a Homebrew install of Apache (the httpd formula), the file is here instead:
/opt/homebrew/etc/httpd/httpd.conf (Apple silicon)
/usr/local/etc/httpd/httpd.conf (Intel Macs)
To confirm which file the built-in Apache reads, ask it:
/usr/sbin/httpd -V | grep SERVER_CONFIG_FILE
On the Mac used for this guide that printed /private/etc/apache2/httpd.conf.
/etc is hidden in Finder. Choose Go > Go to Folder (or press ⇧⌘G), type /etc/apache2 and press Return. From Terminal:
open /etc/apache2
To read the file without changing it:
less /etc/apache2/httpd.conf
To edit it you need administrator rights, because the file belongs to root. In Terminal, sudo nano /etc/apache2/httpd.conf works. Copy the file first (sudo cp /etc/apache2/httpd.conf /etc/apache2/httpd.conf.bak) so you can roll back.
| Path | What it is |
|---|---|
httpd.conf | The main file. Sets the port, the user Apache runs as, which modules load, and the document root. |
extra/ | Optional config snippets such as httpd-vhosts.conf, httpd-ssl.conf and httpd-userdir.conf. Most are switched on by uncommenting an Include line in httpd.conf. |
other/ | Files here are loaded automatically, because httpd.conf ends with Include /private/etc/apache2/other/*.conf. This is the tidy place for your own settings. |
users/ | Per-user site files (<name>.conf). They load only after you switch on per-user sites, because the line that includes them is commented out in extra/httpd-userdir.conf. |
original/ | Pristine copies of the stock httpd.conf and extra/ files, handy for comparing against your edits. |
mime.types, magic | Lookup tables. Rarely edited. |
On the Mac used for this guide, the stock file sets ServerRoot "/usr", runs Apache as user _www, and has #LoadModule rewrite_module and #LoadModule userdir_module commented out. A leading # means off, so remove it to enable a module.
Check these in httpd.conf rather than trusting a tutorial, because they can be changed:
/Library/WebServer/Documents in the stock file. A fresh macOS holds one placeholder page there./private/var/log/apache2/error_log, set by the ErrorLog line. The folder can be empty until Apache first runs.Listen 80, and a Listen 8080 line inside an IfDefine block that applies to a different setup. Homebrew's httpd formula sets its own default port to 8080 (and 8443 for SSL) so it can run without sudo.Homebrew's own document root is /opt/homebrew/var/www (or /usr/local/var/www on Intel), per the formula page.
Always check the syntax first. A typo stops Apache starting.
sudo apachectl configtest
If it says Syntax OK, restart or reload:
sudo apachectl restart
For a Homebrew Apache, use brew services restart httpd instead. Homebrew's formula also documents running it directly with $(brew --prefix)/opt/httpd/bin/httpd -D FOREGROUND.
If you have installed httpd with Homebrew, you now have two servers with two config files and, possibly, two document roots. which httpd shows which one your shell picks up. On Apple silicon with Homebrew's usual setup that is /opt/homebrew/bin/httpd, while /usr/sbin/httpd is always the built-in one. If your Mac has both Homebrew prefixes (common on Apple silicon Macs that once ran Intel Homebrew), run ls /opt/homebrew/etc/httpd /usr/local/etc/httpd to see which, if either, has a config.
/etc/apache2 is part of the operating system's own files, and a major macOS update can restore or replace files there. Keep your own settings in a new file in other/ (for example /etc/apache2/other/mysite.conf) instead of editing httpd.conf, and keep a copy of it somewhere in your home folder. That is a habit, not a documented guarantee, but it costs nothing and makes a post-update fix a two-minute job.
Two features people usually want are the rewrite module and per-user sites. In httpd.conf, remove the leading # from the LoadModule rewrite_module line to enable rewrites. Per-user sites need LoadModule userdir_module and the Include line for extra/httpd-userdir.conf, both commented out in the stock file, plus the Include /private/etc/apache2/users/*.conf line inside httpd-userdir.conf. Its stock UserDir Sites setting then serves each account's ~/Sites folder. After each change, run sudo apachectl configtest and then restart. If Apache refuses to start, put the .bak copy back and try again with one change at a time.
/etc is a hidden system folder and /opt/homebrew sits outside your home folder, and Spotlight and Finder searches leave results from both out.
When you are not sure whether the live config is the system one or a Homebrew one, type httpd.conf into Everywhere. Both copies show up at once, along with the pristine one in original/, and ⌘↵ reveals the one you pick in Finder. It matches file names only, not the directives inside, so use grep for those. Everywhere covers /etc and Homebrew's folders as part of its normal scan.
For the Apache built into macOS it is /etc/apache2/httpd.conf (the same file as /private/etc/apache2/httpd.conf). A Homebrew Apache uses /opt/homebrew/etc/httpd/httpd.conf on Apple silicon or /usr/local/etc/httpd/httpd.conf on Intel.
Run /usr/sbin/httpd -V | grep SERVER_CONFIG_FILE for the built-in server. For a Homebrew install, httpd -V from its own bin folder reports its own path.
The stock httpd.conf sets DocumentRoot to /Library/WebServer/Documents. Check the DocumentRoot line in your own file, since it can be changed.
The stock config writes the error log to /private/var/log/apache2/error_log, as set by its ErrorLog line.
Everywhere keeps track of every file on your Mac — including the folders Spotlight hides and drives you have unplugged. Free for a day, then $19 once.
Version 2.20.3 · macOS 13+ · 4.7 MB · notarised