I'm trying to set up virtual hosts on Mac OS X. I've been modifying httpd.conf and restarting the server, but haven't had any luck in getting it to work. Furthermore, I notice that it's not serving files in the DocumentRoot mentioned in httpd.conf (Libraries/WebServer/Documents), but in a different directory (/usr/local/apache2/htdocs). I don't see this folder mentioned anywhere in httpd.conf. Furthermore, PHP works, but the "LoadModule php5_module" line is commented out. This makes me think it's using another .conf file. How can I figure out which config is actually being loaded?
Update: I just deleted that httpd.conf and apache behaves the same after restart, so it definitely wasn't using it!
With any *nix application, the easiest method is to query the binary itself. In the case of httpd, I'd imagine the process would be something like this:
As you can see - my OS X says the binary, if not directed otherwise, will use the config file: /private/etc/apache2/httpd.conf
If that doesn't help, perhaps Christopher's suggestion of find is the next step.
There's another serverfault question regarding this. If you're using a debian based server you can use
apache2ctl
to determine which config file is being used:More on this:
How to find out which httpd.conf apache is using at runtime
Try
and you should (might) get output like
Additionally, how exactly are you restarting the server? Just curious in case you somehow aren't actually re-reading the config file.
Because some configs use Server app, brew or whatever, and because one liners FTW :
This command do the following :
Tested on Sierra & El Capitan
First, check which is the startup script for Apache. For macOS, it should be /Library/LaunchDaemons. That might include a working directory, or similar information.
You could also debug the running process itself with dtruss. You can connect to the running process using
dtruss -p <pid>
. Then, if you HUP it, you can probably pore over the output to see where it's grabbing its config from. Alternately, just start Apache by calling dtruss directly withdtruss start_apache_command
.You could always just do a system-wide search for httpd.conf with
find / -name httpd.conf
.