How to install Apache on MacOS using Homebrew?
Here are list of steps to install Apache httpd on MacOS.
If yo have any of below questions then you are at right place:
- How do I install Apache on my Mac?
- Installing & Configuring Apache on macOS
- How to Install Apache on MacOS?
Let’s get started:
Step-1
Install Homebrew on your Macbook. Please follow this tutorial completely.
Step-2
- Install httpd using below command.
bash-3.2$ brew install httpd
Here is a detailed console output:
bash-3.2$ brew install httpd Running `brew update --preinstall`... ==> Downloading https://ghcr.io/v2/homebrew/core/pcre/manifests/8.45 ######################################################################## 100.0% ==> Downloading https://ghcr.io/v2/homebrew/core/pcre/blobs/sha256:5e5cc7a5bf8bb6488ec57d4263bf6b0bc89e93252a0a2460f846de29373162d8 ==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:5e5cc7a5bf8bb6488ec57d4263bf6b0bc89e93252a0a2460f846de29373162d8?se=2 ######################################################################## 100.0% ==> Downloading https://ghcr.io/v2/homebrew/core/httpd/manifests/2.4.52 ######################################################################## 100.0% ==> Downloading https://ghcr.io/v2/homebrew/core/httpd/blobs/sha256:6a35059e2c3f69635ac6035c0a638030a1038cc62e648604ab53b4a280a88ba8 ==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:6a35059e2c3f69635ac6035c0a638030a1038cc62e648604ab53b4a280a88ba8?se=2 ######################################################################## 100.0% ==> Installing dependencies for httpd: pcre ==> Installing httpd dependency: pcre ==> Pouring pcre--8.45.monterey.bottle.tar.gz 🍺 /usr/local/Cellar/pcre/8.45: 204 files, 5.7MB ==> Installing httpd ==> Pouring httpd--2.4.52.monterey.bottle.tar.gz ==> Caveats DocumentRoot is /usr/local/var/www. The default ports have been set in /usr/local/etc/httpd/httpd.conf to 8080 and in /usr/local/etc/httpd/extra/httpd-ssl.conf to 8443 so that httpd can run without sudo. To restart httpd after an upgrade: brew services restart httpd Or, if you don't want/need a background service you can just run: /usr/local/opt/httpd/bin/httpd -D FOREGROUND ==> Summary 🍺 /usr/local/Cellar/httpd/2.4.52: 1,662 files, 31.7MB ==> Running `brew cleanup httpd`... Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP. Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`). Removing: /Users/app/Library/Caches/Homebrew/httpd--2.4.46.tar.bz2... (6.9MB) ==> No outdated dependents to upgrade! ==> Checking for dependents of upgraded formulae... Disable this behaviour by setting HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK. Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`). ==> Reinstalling 1 dependent with broken linkage from source: httpd ==> Caveats ==> httpd DocumentRoot is /usr/local/var/www. The default ports have been set in /usr/local/etc/httpd/httpd.conf to 8080 and in /usr/local/etc/httpd/extra/httpd-ssl.conf to 8443 so that httpd can run without sudo. To restart httpd after an upgrade: brew services restart httpd Or, if you don't want/need a background service you can just run: /usr/local/opt/httpd/bin/httpd -D FOREGROUND
And you are all set.
Where is Apache httpd installed on my mac?
bash-3.2$ which httpd /usr/local/bin/httpd bash-3.2$
How to Start / Stop Apache httpd server?
bash-3.2$ brew services start httpd ==> Successfully started `httpd` (label: homebrew.mxcl.httpd) bash-3.2$ bash-3.2$ brew services stop httpd Stopping `httpd`... (might take a while) ==> Successfully stopped `httpd` (label: homebrew.mxcl.httpd)
Let me know if you face any issue installing Apache on MacOS.