macOS Homebrew – Managing Apache Installs in Different Directories

apachehomebrewmacos

Im strugling to understand different installations of apache on macOS.
As i now can say i have two installations of apache2 one in
/private/etc/apache2 ->this one seams to be installed by default with the system
/usr/local/etc/apache2/2.4 ->this one i install with brew

if i brew install/uninstall httpd24 it un/installs a symlink in /usr/local/bin/apachectl that makes the brew server under /usr/local/etc/apache2/2.4 start. But as i read (if i understand correctly) macOS comes with apache in /private/etc/apache2 wich when already running and i install brew it doesn't take the apachectl commands anymore… so im not able to stop it until i brew uninstall httpd24 and then sudo apachectl stop.

i can reach localhost:80 ->system apache
and localhost:8080 -> brew apache

so how can i controll the system apache when i have brew version installed?

Best Answer

TL:DR; Use /usr/sbin/apachectl

The issue is that you have bins for both versions, and as they have the same name. Your .bashrc / .bash_profile configuration will determine the order bin folder are included, which determines which wins.

It's generally a good idea to /usr/local/bin win, as this is stuff you installed yourself and not something that comes with the OS by default.

The location of the apachectl script for the apache installed on macOS is located in /usr/sbin, so you can run it directly using /usr/sbin/apachectl. Alternately you can make an alias or symlink for this to make a unique command.