Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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!

share|improve this question

4 Answers 4

up vote 21 down vote accepted

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:

$ whereis httpd
/usr/sbin/httpd
$ /usr/sbin/httpd -V
Server version: Apache/2.2.11 (Unix)
Server built:   Jun 17 2009 14:55:13
Server's Module Magic Number: 20051115:21
Server loaded:  APR 1.2.7, APR-Util 1.2.7
Compiled using: APR 1.2.7, APR-Util 1.2.7
Architecture:   64-bit
Server MPM:     Prefork
  threaded:     no
    forked:     yes (variable process count)
Server compiled with....
 -D APACHE_MPM_DIR="server/mpm/prefork"
 -D APR_HAS_SENDFILE
 -D APR_HAS_MMAP
 -D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
 -D APR_USE_FLOCK_SERIALIZE
 -D APR_USE_PTHREAD_SERIALIZE
 -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
 -D APR_HAS_OTHER_CHILD
 -D AP_HAVE_RELIABLE_PIPED_LOGS
 -D DYNAMIC_MODULE_LIMIT=128
 -D HTTPD_ROOT="/usr"
 -D SUEXEC_BIN="/usr/bin/suexec"
 -D DEFAULT_PIDLOG="/private/var/run/httpd.pid"
 -D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
 -D DEFAULT_LOCKFILE="/private/var/run/accept.lock"
 -D DEFAULT_ERRORLOG="logs/error_log"
 -D AP_TYPES_CONFIG_FILE="/private/etc/apache2/mime.types"
 -D SERVER_CONFIG_FILE="/private/etc/apache2/httpd.conf"

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.

share|improve this answer
    
This won't work if you're using Apache via the Server.app In that case you'll need the process list in the answer from @msanford serverfault.com/a/155114/187798 which shows that the Server.app starts httpd with a different configuration file as shown here from my installation (Mavericks) /usr/sbin/httpd -D FOREGROUND -f /Library/Server/Web/Config/apache2/httpd_server_app.conf -D WEBSERVICE_ON –  Jason S Dec 1 '13 at 3:16
    
also does not work with when using apache installed via macports -- answer by msandord works for me! –  pgee70 Jun 17 at 9:53

Try

ps ax | grep httpd

and you should (might) get output like

1633   ??  Ss     0:00.21 /usr/sbin/httpd -f /etc/httpd.conf

Additionally, how exactly are you restarting the server? Just curious in case you somehow aren't actually re-reading the config file.

share|improve this answer
    
hm it doesn't have the -f flag in it –  Claudiu Jun 26 '10 at 15:50
1  
+1 As this is the only answer that works for all cases, that is if you're configuring Apache yourself or if you're using Apache via Server.app –  Jason S Dec 1 '13 at 3:17

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:

apache2ctl -V

More on this:

How to find out which httpd.conf apache is using at runtime

share|improve this answer
    
This helped, better than other answers, thanks! –  Mārtiņš Briedis Jul 8 at 22:04

A couple things. First, check the startup script for Apache. I'm assuming it's in /etc/init.d/httpd? For OSX, it's /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. dtruss start_apache_command.

Third, you could always just do a system wide find for 'httpd.conf'. find / -name httpd.conf


--Christopher Karel

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.