I have been trying to figure out how to completely remove preinstalled Apache and PHP from my macbook pro ... The reason is that I am using the homebrew version of both Apache and PHP. The current version of PHP that I am using is PHP 7 as you can see in the screenshot below

Localhost PHP Version

but when I use php -v in the terminal it shows me PHP version 5.6 .. see screenshot below.

enter image description here

I am trying to find the preinstalled PHP but can't seem to find it ... Can you guys help me out and point me to the right direction ? Thank You.

  • 3
    The correct way ios not to uninstall the ones Apple installed as Apple will put them back. The correct way is to use the path to find the homebrew ones first. What is your path? – Mark Aug 29 '17 at 10:33
  • 1
    My preferred way is to ignore the ones on the Mac and light up a VM with text only FreeBSD (no GUI desktop) and load the AMP stack there. – Allan Aug 29 '17 at 12:35

Removing system macOS binaries is not a good idea, they will be reinstalled during a next system upgrade and they could be needed by some system scripts.

To enable the homebrew php from the command line, read the output of brew info php70:

If you wish to swap the PHP you use on the command line, you should add the following to ~/.bashrc, ~/.zshrc, ~/.profile or your shell's equivalent configuration file: export PATH="$(brew --prefix homebrew/php/php70)/bin:$PATH"

If you have installed php 7.2, check the output of brew info php72.

  • Thanks .... Yes i know that uninstalling native binaries is not a good idea ... But i thought that it was conflicting with the ones i have installed using Homebrew ... I will check according to your suggestion – FaISalBLiNK Aug 30 '17 at 17:11
  • 1
    There is no conflict. The PATHenvironment variable define the priority between binaries with the same name. If a directory is placed before another one in the PATH, its binaries will have the priority. – Ortomala Lokni Aug 30 '17 at 17:18
  • 1
    Far better to use the PATH variable and control which version is preferred, loads first. apple.stackexchange.com/questions/592/… good answer – bmike Dec 8 '17 at 10:27
  • 1
    This is exactly what is proposed by homebrew and by this answer. – Ortomala Lokni Jan 31 '18 at 16:44

I've tried this

export PATH=/usr/local/php5/bin:$PATH

and it works, php -v is showing me the correct version, see https://php-osx.liip.ch/#faq

!!! Note that you need to add export PATH=/usr/local/php5/bin:$PATH to your ~/.bash_profile file in order to have this change permanent, otherwise it will go away on first reboot and you'll have to run this command every time you reboot.


Export your PATH with some like this (check your php version):

export PATH=/usr/local/Cellar/php71/7.1.14_25/bin:$PATH

  • 1
    How does this improve on other answers they say set the path – Mark Mar 30 '18 at 14:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .