OSX how to show apache status in terminal?

How about in the apachectl wrapper script you stick something like this at the end.

tail -5 /var/log/httpd/error_log

you should see something like this in a normal startup

  • [Fri Apr 22 23:39:20 2011] [notice] Digest: generating secret for
    digest authentication ...
  • [Fri Apr 22 23:39:20 2011] [notice] Digest: done
  • [Fri Apr 22 23:39:20 2011] [warn] pid file
    /mlk/apache/pid/httpd.pid overwritten -- Unclean shutdown of previous Apache run?
  • [Fri Apr 22 23:39:20 2011] [notice] Apache/2.0.63 (Unix) DAV/2 configured -- resuming normal operations

Otherwise any error should at least in part be shown here. The key phrase is hilighted above.

Additional: /usr/sbin/apachectl is owned by root, you must be a privileged user to do this. sudo vi /usr/sbin/apachectl

move to the end of the file and insert this between the "esac" and "exit $ERROR" lines. ie.

esac
sleep 2; tail -5 /var/log/httpd/error_log
exit $ERROR

Note this will print out the last few lines no matter what action you take with the script, stop start, restart. you may want to only put it in the start part of the case statement.


I have the same problem on my mac. When ever I attempt to start apache and nothing happens, I immediately run this command. In my case the problem always seems to be in the apache configuration files.

apachectl configtest

apachectl on the Mac is a wrapper around some launchctl commands (just look into the file). Unfortunately, launchctl doesn't exit with an error code when something goes wrong with starting httpd, so the script has no easy way to display anything, even if it tries to.

A basic check you can perform yourself is to check the existence of Apache processes after the apachectl start command.

ps aux | grep httpd