Controlling which Apache install is run by 'apachectl'

Hi. I’m knew to the Homebrew world.

I recently installed Homebrew on my MacMini and used it to get the latest version of Apache.
(The built-in version of Apache was only v2.4.34 which lacks some security updates.)

A question I have is: How does Terminal (or the Mac OS for that matter), know which Apache version to run when you type commands like ‘sudo apachectl start’. (I can tell it’s running the new Homebrew version.)

The reason I ask is that I am migrating a configuration from the old Apache to the new Homebrew version. I think I can figure out how to modify the new configuration files to make the new install work like the old, but it would be nice to be able to switch between the two Apache versions.

For example, my current production server “works”, but I’m not confident the new one will, so it would be nice to be able to switch between the two on the fly. Is this possible?

Thanks. (Great installer BTW).
dave nasralla

I’m not sure I’d recommend homebrew to install production environments, generally the intended audience when making changes are developers so you might end up with a ton of bloat and unstable software.

Having said that, those things are determined by your PATH variable. https://kb.iu.edu/d/acar for more info

Hi Sean. Thanks for the advice. The reason I went with Homebrew is because outside security scans are finding vulnerabilities in the older version. The site is quite simple and I’m willing to test out Homebrew.

I think I understand better now. So it looks like Homebrew did not change the $PATH variable at all, but rather placed symbolic links in the usr/local/bin/ directory, which by default is where the Mac OS looks first for the program to run.

When I remove the symbolic link in that directory, it runs the original apache version. This is what I was looking for. Thanks for pointing me in the right direction.

dave