# How to properly and for once reinstall PHP/Apache

So I'm struggeling with this since a long time and I'd like to find a proper solution.

I have php5.4.. install and I want to upgrade to Php 7.

No matter how hard I'm trying to do it I can't seems to touch my goal. I tried to remove php54 and other with homebrew, to remove it manually by command line, to overwrite it with new version nothing work. What ever Im doing when I type php -v I always end up with php5.4 :

Marjorie:~ Mawel$php -v PHP 5.4.45 (cli) (built: Sep 6 2015 20:56:23) Copyright (c) 1997-2014 The PHP Group Zend Engine v2.4.0, Copyright (c) 1998-2014 Zend Technologies  So I'm asking my self have I messed up with my php/apache conf ? Shall I try a clean-install of my system and would it be efficient ? I don't know ! I'm kinda lost and really need some help even for comprehension (is there a reason I can't get rid of old php version ?) Anything would be helpful ## Edit So here is more information for answering the questions : Output of brew tap Marjorie:~ Mawel$ brew tap
homebrew/dupes
homebrew/php
homebrew/versions


As of what I've tried with home brew : So here is step by step the idea :

brew remove php54
brew install php70


Marjorie:~ Mawel$sudo find ~/ -iname "php" /Users/Mawel//Code/agencedevoyage/sos-partenaire/vendor/phpunit/php-code-coverage/tests/PHP /Users/Mawel//Code/agencedevoyage/sos-partenaire/vendor/phpunit/phpunit/src/Util/PHP /Users/Mawel//Code/agencedevoyage/vendor/phpunit/php-code-coverage/tests/PHP /Users/Mawel//Code/agencedevoyage/vendor/phpunit/phpunit/src/Util/PHP /Users/Mawel//Code/PHP /Users/Mawel//Code/Site Perso/dev/vendor/phpunit/php-code-coverage/tests/PHP /Users/Mawel//Code/Site Perso/dev/vendor/phpunit/phpunit/src/Util/PHP /Users/Mawel//Documents/Cours/BTS SIO/Developpement/PHP /Users/Mawel//Documents/Cours/BTS SIO/Developpement/web/php /Users/Mawel//Library/Application Support/Sublime Text 3/Cache/PHP /Users/Mawel//Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/IPython/html/static/components/codemirror/mode/php  And finally, my bash profile : Marjorie:~ Mawel$ vi ~/.bash_profile

alias composer="php /usr/local/bin/composer.phar"
PATH="/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:$PATH" export PATH export PATH=~/.composer/vendor/bin:$PATH
export PATH="/usr/local/mysql/bin:$PATH" source ~/.profile  • Calm down mate :) First of all tell us what brew commands have you tried and brew list which php version gives you – AlessioX Mar 16 '16 at 19:34 • Also, what's the output for brew tap? – AlessioX Mar 16 '16 at 19:41 • @Alessiox Edited my post – Baldráni Mar 17 '16 at 10:55 • Since you're working with homebrew, first of all I'd suggest to brew update and brew cleanup to remove older formula versions and leftovers/cache. Then in your PATH try putting usr/local/bin (where brew links stuff) before usr/bin (the apple standard) – AlessioX Mar 17 '16 at 11:12 • As you can see the default php is not the homebrew php but the standard Mac OS X. Mac OS X as you might know, scans the PATH from top to bottom when looking for executables and binaries, so the usr/local/bin path (which is the homebrew path) should be at the top of the PATH (or, at least, before usr/bin. Try changing the bash_profile including the brew path at the top of the PATH, then restart and try again with which pip or pip -v and see if something changes. – AlessioX Mar 17 '16 at 12:48 ## 1 Answer The brew commands look ok. You have all the taps you need. First of all since you're working with homebrew, I'd suggest the following two commands (let's start clean): brew update && brew cleanup  So we're sure that we're using the latest homebrew release and we cleanup all old formulas and leftovers. From your PATH it looks like usr/bin (which is the standard Mac OS X path for binaries and executables) comes before usr/local/bin (the path in which homebrew links the Cellar). As you might know, Mac OS X when looking for binaries/executables scans the PATH from top to bottom so if both usr/bin and usr/local/bin have the php executables, since usr/bin comes first in PATH, then Mac OS X will use the php version in such folder, ignoring the version in usr/local/bin (which, as instead, is our target). To make sure regarding which version Mac OS X is using, type in the Terminal which php  and if the output is usr/bin, then Mac OS X is using its own version. The core indeed now is to change the PATH order in bash_profile, and make sure that usr/local/bin comes before usr/bin (it is clear now that we're forcing Mac OS X to use the homebrew version). Once the changes have been done, restart your Mac and type in the Terminal echo$PATH


This will display the entire PATH list so you can make sure everything's in the right order.
Now, finally, you can check using either

which php


or

php -v


which is the running version.