Apache2 (Httpd) not working after update to High Sierra

apachehigh sierrahomebrew

I have an issue where Apache will not start after updating to High Sierra 10.13.1. There isn't anything showing in the error logs, but when I try to apachectl start nothing happens. If I run apachectl configtest I receive "Syntax OK

I have used commands like sudo launchctl load -w /System/Library/LaunchDaemons/org.apache.httpd.plist to no avail. Apache will not start. I can run sudo launchctl load -w /Library/LaunchDaemons/homebrew.mxcl.httpd.plist and that is not working either.

I took a look at the brew services list and httpd shows up in the list along with other process (mysql) but httpd's status is showing a yellow "started" instead of a green one.

I have tried many different things, and what I am finding is that if I look into the system.log file I find com.apple.xpc.launchctl[1] (homebrew.mxcl.httpd24[11780]): Service exited with abnormal code:1

If I run apachectl start, the command seems to work, but when I run the stop command I get "httpd (no pid file) not running.
I am also receiving the output of com.;apple.xpc.launchd[1] (org.apache.httpd): Please switch away from OnDemand to KeepAlive.

Is there something with High Sierra that is preventing Apache from running when it ran fine in Sierra?

Best Answer

In my opinion you hosed your various httpd launch daemons/start mechanisms by executing too many httpd related commands.

With homebrew and homebrew's apache-httpd installed and the default PATH you have six ways to start httpd.

Apple's Apache:

  • sudo launchctl load -w /System/Library/LaunchDaemons/org.apache.httpd.plist
  • sudo /usr/sbin/apachectl start

Homebrew's Apache:

  • sudo apachectl start
  • apachectl start
  • sudo brew services start httpd
  • brew services start httpd

If you've copied the file homebrew.mxcl.httpd.plist manually to either ~/Library/LaunchAgents/ or /Library/LaunchDaemons/ you have two more options to start it by loading them with (sudo) launchctl load ....

If you didn't modify the httpd config files or the apachectl scripts heavily the Apple branch will use Apple's httpd.conf file in /var and the DocumentRoot in the /Library folder.

The homebrew branch uses subfolders in /usr/local/.

Some launch methods won't work if you've bound the httpd ports to ports lower than 1024!

If you use (sudo) brew services ... to start httpd you have to use the proper (sudo) brew services list command to check the status:

If you start it as root then list it with root privs:

sudo brew services start httpd > sudo brew services list

or with user privs:

brew services start httpd > brew services list.


To solve your problem unload Apple's httpd:

  • sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist
  • remove any manually installed homebrew.mxcl.httpd.plist
  • stop any homebrew httpd service with (sudo) brew services stop httpd
  • stop any httpd started by apachectl:

    apachectl stop
    sudo apachectl stop
    sudo /usr/sbin/apachectl stop
    
  • Open Activity Monitor and check that no httpd process is running.
  • Reboot

Now - assuming you want to use homebrew's httpd on privileged ports - enter:

sudo brew services start httpd

Check the successful start with sudo brew services list.