Apache2 (Httpd) not working after update to High Sierra
Solution 1:
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
.
Solution 2:
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.