After installing httpd24 with brew you have two completely different Apache web server environments:
- brew's httpd24
- the original macOS/OS X httpd
Both have different config files and apachectl (and other) binaries. The first one is installed to /usr/local/Cellar/httpd24 and its binaries are linked to /usr/local/bin. macOS' httpd related binaries are located at /usr/sbin.
Depending on your PATH variable (enter
echo $PATH to get it)
sudo apachectl [cmd] either controls the first or the second Apache environment.
After installing brew the default PATH should be
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin which favors brew's httpd24. You can control macOS' Apache by using the full path (/usr/sbin/apachectl) though.
If you have a different path which doesn't favor /usr/local/bin over /usr/sbin it's the other way round. To get the path of the favored apachectl you can also simply enter
Check this with
/usr/local/bin/apachectl -S which should yield:
Main DocumentRoot: "/usr/local/var/www/htdocs"
Main ErrorLog: "/usr/local/var/log/apache2/error_log"
Mutex default: dir="/usr/local/var/run/apache2/" mechanism=default
Mutex mpm-accept: using_defaults
User: name="daemon" id=1 not_used
Group: name="daemon" id=1 not_used
Main DocumentRoot: "/Library/WebServer/Documents"
Main ErrorLog: "/private/var/log/apache2/error_log"
Mutex default: dir="/private/var/run/" mechanism=default
Mutex mpm-accept: using_defaults
Mutex proxy-balancer-shm: using_defaults
Mutex proxy: using_defaults
User: name="_www" id=70 not_used
Group: name="_www" id=70 not_used
There are no mutually used files/folders.
They also use different standard config files:
/usr/local/bin/apachectl -t -D DUMP_INCLUDES
Included configuration files:
The command doesn't work properly for the original (macOS) apachectl though and only yields: Syntax OK.
If you run both httpds (configuring different ports here: 80: macOS; 8080 httpd24 - check this in the respective config files)
ps -aef | grep httpd | grep -v grep will show the following:
0 76 1 0 4:54pm ?? 0:00.13 /usr/local/opt/httpd24/bin/httpd -D FOREGROUND
1 219 76 0 4:54pm ?? 0:00.00 /usr/local/opt/httpd24/bin/httpd -D FOREGROUND
1 220 76 0 4:54pm ?? 0:00.00 /usr/local/opt/httpd24/bin/httpd -D FOREGROUND
1 221 76 0 4:54pm ?? 0:00.00 /usr/local/opt/httpd24/bin/httpd -D FOREGROUND
1 222 76 0 4:54pm ?? 0:00.00 /usr/local/opt/httpd24/bin/httpd -D FOREGROUND
1 223 76 0 4:54pm ?? 0:00.00 /usr/local/opt/httpd24/bin/httpd -D FOREGROUND
1 4239 76 0 5:06pm ?? 0:00.00 /usr/local/opt/httpd24/bin/httpd -D FOREGROUND
0 8251 1 0 5:45pm ?? 0:00.08 /usr/sbin/httpd -D FOREGROUND
70 8261 8251 0 5:46pm ?? 0:00.00 /usr/sbin/httpd -D FOREGROUND
The first seven pids belong to httpd24, the last two to macOS' httpd - check the binary paths listed!
Starting Nmap 7.31 ( https://nmap.org ) at 2016-12-22 18:00 CET
Nmap scan report for localhost (127.0.0.1)
Host is up (0.00039s latency).
Other addresses for localhost (not scanned): ::1 fe80::1
Not shown: 499 closed ports, 498 filtered ports
PORT STATE SERVICE
80/tcp open http
8080/tcp open http-proxy
In your private chat message you can clearly see that httpd24 isn't running at all, but macOS' httpd is.
To disable macOS' httpd simply run
sudo /usr/sbin/apachectl stop and additionally
sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist (just to be sure).
Then dump the
brew service start ... method by stopping the service and installing a real plist daemon like recommended in the linked how-to.
sudo cp -v /usr/local/Cellar/httpd24/2.4.23_2/homebrew.mxcl.httpd24.plist /Library/LaunchDaemons
sudo chown -v root:wheel /Library/LaunchDaemons/homebrew.mxcl.httpd24.plist
sudo chmod -v 644 /Library/LaunchDaemons/homebrew.mxcl.httpd24.plist
sudo launchctl load /Library/LaunchDaemons/homebrew.mxcl.httpd24.plist
Reboot. If you still get an error connecting with localhost:8080 to your local developer site comment out
fe80::1%lo0 localhost in /etc/hosts. In my environment it works with this line though.
After further investigations it turns out that a misconfigured web proxy (part of ESET's Internet Security/Antivirus) is the culprit. By adding a proper
localhost exclude it should be possible to solve the problem.