Switching from Default Apache to Homebrew Apache on MacOS
— Apache, Homebrew, Guide, MacOS — 1 min read
Even though Apache is already installed on macOS, there is a better-maintained version with Homebrew.
In this guide, we will disable the default apache on mac restart also we will install the homebrew apache version.
Stop & Disable Apache
First of All, open the terminal and check if Apache is running on Port 80 by this command:
sudo lsof -i:80
The output you may get would be:
This tells us that the Apache is running and if no output would mean it's not running.
The next step is to stop and disable Apache on mac restart by this command:
sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist
Install Apache with Homebrew
Make sure you already have Homebrew installed, if not you can follow the step from official homebrew installation, then the next step is to install apache httpd by this command:
brew install httpd
Last but not least, start or restart the apache homebrew with this command:
brew services start httpd
brew services restart httpd
and command for stop:
brew services stop httpd
By default the Apache Homebrew is listening on Port 8080, check by this command:
sudo lsof -i:8080