Mac OS X Server 10.0: httpd Processes Can Refuse to Quit

Depending on load, the Apache Web server may create additional instances of itself. Sometimes the additional instances of Apache do not quit as expected.
Symptom

ProcessViewer or top indicates that many instances of httpd process are running when the server is under light load.


Solution

Use one of the following solutions (A or B).

A. Disable logging

If you do not need a log, you may disable logging by using Server Admin. Follow these steps:

Note: If you are hosting more than one Web site, you should change this setting for each site.

B. Change the logging method

If you need a log, follow these steps to change the method that Mac OS X Server uses to log Web server information. The script presented here logs one week of data and then deletes the oldest log file.

First, disable the logs' Archive feature if it is enabled. Follow these steps:

Note: If you are hosting more than one Web site, you should change this setting for each site.

Next, you need to edit the /etc/daily file. Follow these steps:


Begin copying below this line.

echo ""
echo -n "Rotating Apache log files:"
cd /var/log/httpd
for i in httpd.log; do
if [ -f "${i}" ]; then
echo -n " ${i}"
if [ -x /usr/bin/gzip ]; then gzext=".gz"; else gzext=""; fi
if [ -f "${i}.6${gzext}" ]; then mv -f "${i}.6${gzext}" "${i}.7${gzext}"; fi
if [ -f "${i}.5${gzext}" ]; then mv -f "${i}.5${gzext}" "${i}.6${gzext}"; fi
if [ -f "${i}.4${gzext}" ]; then mv -f "${i}.4${gzext}" "${i}.5${gzext}"; fi
if [ -f "${i}.3${gzext}" ]; then mv -f "${i}.3${gzext}" "${i}.4${gzext}"; fi
if [ -f "${i}.2${gzext}" ]; then mv -f "${i}.2${gzext}" "${i}.3${gzext}"; fi
if [ -f "${i}.1${gzext}" ]; then mv -f "${i}.1${gzext}" "${i}.2${gzext}"; fi
if [ -f "${i}.0${gzext}" ]; then mv -f "${i}.0${gzext}" "${i}.1${gzext}"; fi
if [ -f "${i}" ]; then mv -f "${i}" "${i}.0"; fi
touch "${i}" && chmod 640 "${i}"
/usr/sbin/apachectl restart
if [ -x /usr/bin/gzip ]; then gzip -9 "${i}.0"; fi
fi
done

End copying above this line.
5. Save the file (press Control-O), press Return, and exit pico (press Control-X).

Note: This will stop the Web server momentarily to let it start logging to the new files.
Published Date: Feb 17, 2012