3

I'm trying to setup httpd with HomeBrew on a mac.

As I painfully learned today, brew services start always reports success, even when httpd fails to start.

Example failures reported as success:

  • failure to start httpd because another instance (started outside of brew) is already running;
  • failure to start httpd because of a syntax error in a config file

For example, say I deliberately put some random chars in httpd.conf, and run:

$ sudo brew services restart httpd

Brew happily reports success:

==> Successfully stopped `httpd` (label: homebrew.mxcl.httpd)
Warning: Taking root:admin ownership of some httpd paths:
  /usr/local/Cellar/httpd/2.4.41_1/bin
  /usr/local/Cellar/httpd/2.4.41_1/bin/httpd
  /usr/local/opt/httpd
  /usr/local/opt/httpd/bin
  /usr/local/var/homebrew/linked/httpd
This will require manual removal of these paths using `sudo rm` on
brew upgrade/reinstall/uninstall.
==> Successfully started `httpd` (label: homebrew.mxcl.httpd)

Even though httpd is obviously not running:

$ sudo ps -A |grep httpd
 9481 ttys000    0:00.01 grep httpd
 (nothing else)
$ sudo lsof -iTCP:80 -sTCP:LISTEN
 (nothing)

What's wrong? Is this a bug in brew?

3
  • 1
    Why don't you open an issue under Homebrew/brew? – Simba Sep 14 '19 at 9:44
  • 1
    I'm having this exact same issue. Did you ever resolve this? To make it worse Homebrew THINKS apache is running, but when you looks at the processes it isn't – Adam Christianson Dec 24 '19 at 1:16
  • 1
    @AdamChristianson Unfortunately not. I moved away from MacOS after trying it for a few days, due to too many issues like this one. – BenMorel Dec 24 '19 at 11:23
3

Trying to debug Apache issues on any computer can be difficult, but you just have to know what commands and files to look at. First, try to start Apache using the apachectl command and look for errors written to the screen.

$ sudo apachectl start

If there is an error in the apache conf files or some system issue, you may see it there.

Also, you need to review the log file and see what the service is writing about itself. For homebrew, the log file is typically called -

/usr/local/var/log/httpd/error_log

Often, when I find that Apache won't start, it is because there is a pid lock file that makes Apache think another instance is already running and you will see this in the log file. Delete the lock file and try to start the service again.

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

One final note, a great resource for using homebrew to get a LAMP environment up and running on OSX is from Andy Miller over on getgrav.org (https://getgrav.org/blog/macos-catalina-apache-multiple-php-versions). Follow those instructions and you're ready to go..

You must log in to answer this question.

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