9

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?

  • 1
    You are mixing brew's Apache httpd and Apple's Apache httpd (whose launch daemons start different binaries)! Where do you get the httpd status from (ie yellow vs. green indicator)? Which initial set-up guide did you use? – klanomath Nov 17 '17 at 16:28
  • I am not mixing them, I was going through the steps of using trying both brew and Apple's apache, When I perform a brew services list' I receive a yellow indicator, I checked with all of the available users and ran brew services list` and they are all showing the same indicator. As for a setup guide, Ansible was used to set up apache. This has been done on 5 other MacBooks, they are still running Sierra. This one MacBook had an issue and an Apple ran a diagnostic and reset the OS, while updating the OS to High Sierra – Alcyeonnero Nov 17 '17 at 16:45
  • With mixing I mean: you have at least two apachectl and httpd binaries installed (and two config files). Usually brew's apachectl is preferred (because of the default content of the PATH variable, your's may be different though). AFAIR brew's apachectl won't start Apple's httpd with the default start option (ie apachectl start). Same with ... configtest! – klanomath Nov 17 '17 at 16:54
  • With "Ansible was used to set up apache" you mean this guide: Mac Development Ansible Playbook? It's better to add a link to a/the how-to or set-up guide. The various set-up guides for the various macOS versions all contain slightly different configs/create different envs. – klanomath Nov 17 '17 at 17:04
  • I just updated to High Sierra this weekend, and I am having this exact same problem. I have been using the Homebrew httpd formula, and now apache doesn't respond. When I do brew services list, I also get the started for httpd in yellow, and when I run sudo apachectl stop, it tells me that httpd (pid 87?) not responding. – wonder95 Jan 8 '18 at 22:44
10

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.

  • When attempting the fix you provided, I receive the same output as I did. apachectl stop provides the output of httpd (no pid file) not running and when I run sudo brew services httpd start sudo brew services list indicates apache2 (httpd) started in a yellow color When I attempt to access anything webpage related I am unable to. I am wondering if the update to 10.13 altered something in apache preventing it from starting. – Alcyeonnero Nov 20 '17 at 15:55
10

Regarding homebrew httpd, one issue I recently ran into was an old leftover httpd.pid file that was preventing httpd from starting. Symptom was apachectl start said httpd is already running, but it was not.

Cause was an old file here:

/usr/local/var/run/httpd/httpd.pid

Solution was to delete this pid file and then httpd started.

  • great! this is my problem when my MBP decides that it's not going to wake from sleep and I have to power-cycle it. – frumbert Sep 24 '18 at 9:07
  • 2
    This solution also worked in MacOS Mojave. Brew thought that Apache was running but there was no httpd in activity monitor. This fixed it. – Vahid Amiri Nov 12 '18 at 19:34
  • This saved me a lot of trouble! – SEJU Dec 7 '18 at 12:10
  • This worked for me as well. I couldn't load any website, and kept getting ERR_CONNECTION_REFUSED. When I attempted to list the services that were running with brew services list I was getting the yellow 'started' status which meant that there was something wrong with the active status of the server. Removing the pid fixed this and now the service list shows the active status as a green 'started' instead now. Thank you for this! – Mike Kormendy Jan 6 at 2:44
2

I faced the same after I upgraded to High Sierra earlier today. I found that the following apache files were replaced with brand new versions. Fortunately for all of these files there existed a FILE~previous file in the same folder. I just copied the ~previous version back to the original ones, restarted apache and everything was fine.

In folder /etc/apache2 :

./httpd.conf
./extra/httpd-vhosts.conf
./extra/httpd-ssl.conf

Example:

cp /etc/apache2/httpd.conf~previous /etc/apache2/httpd.conf
  • In the folder /etc/apache2/extra/ there are approximately 10 files with ~previous appended to them, should all of these be changed, or just the two you mention in the /etc/apache2/extra/ folder – Alcyeonnero Nov 21 '17 at 18:42
  • I would start with httpd.conf and httpd-vhosts.conf files. If you have SSL setup then you would need to update the httpd-ssl.conf as well. The rest depends on if you had changed them earlier. I would use a diff to see if the files have changed e.g. diff httpd.conf httpd.conf~previous on all the other files – Unmesh Nov 22 '17 at 1:25
  • I have started with those files, that did not change anything. – Alcyeonnero Nov 27 '17 at 13:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .