macosapacheosx-yosemite

Apache 2.4.9 Does Not Respect PidFile Directive


Re: Mac OS X Yosemite 10.10.1, Apache 2.4.9

Apache 2.4.9 seems to ignore the PidFile directive, and always creates a process id file at /var/run/httpd.pid. This makes it impossible to launch multiple instances of httpd, each listening on a different port. Apache 2.2.26, for example, did not have this problem.

So see for yourself:

1) Modify Apache's "default" Mac OS X configuration file, /etc/apache2/httpd.conf, to include (just after ServerRoot) a directive such as:

PidFile "/var/log/apache2/apache.pid"

2) Start Apache thusly:

sudo apachectl start

3) Observe that the specified .pid file is missing and instead, Apache has created /var/run/httpd.pid.

How to fix?


Solution

  • This isn't a bug. You've just overlooked the fact that the default configuration includes /etc/apache2/extra/httpd-mpm.conf, which sets PidFile on line 12:

    #
    # PidFile: The file in which the server should record its process
    # identification number when it starts.
    #
    # Note that this is the default PidFile for most MPMs.
    #
    <IfModule !mpm_netware_module>
        PidFile "/private/var/run/httpd.pid"
    </IfModule>