Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mac upgrading native php with homebrew, not getting it to work

I tried to update the native php of my mba from 5.3.X to 5.4.X I did this: brew tap homebrew/dupes brew tap josegonzalez/homebrew-php brew update brew install php54

This installs php 5.4 on /usr/local/cellar/php54 now when doing which php, it gives me /usr/bin/php

I tried to add this to ~/.bashrc : export PATH=/usr/local/cellar/php54:$PATH

Now when i re-open terminal and type which php it still tells me php is located in /usr/bin/php

Is there a good way to fix this issue?

like image 622
squirreldev Avatar asked Sep 14 '13 21:09

squirreldev


People also ask

How do I get PHP to work on my Mac?

Before you can enable PHP on a Mac, you first have to enable Apache. Both PHP and Apache are free open source software programs and both come installed on all Macs. PHP is server-side software, and Apache is the most widely used web server software. Enabling Apache and PHP on a Mac isn't difficult to do.


2 Answers

From https://github.com/josegonzalez/homebrew-php

If you would like to swap the PHP you use on the command line, you should update the $PATH variable in either your .bashrc or .bash_profile:

# Swapping from PHP53 to PHP54
# export PATH="$(brew --prefix josegonzalez/php/php53)/bin:$PATH"
export PATH="$(brew --prefix josegonzalez/php/php54)/bin:$PATH"

Please be aware that you must make this type of change EACH time you swap between PHP minor versions. You will typically only need to update the Apache/FPM when upgrading your php patch version.

like image 147
Gaston Sanchez Avatar answered Oct 18 '22 09:10

Gaston Sanchez


It is usually that the path wasn't exported properly so not only php but many other brew installations might not be working, try this one:

echo export PATH='/usr/local/bin:$PATH' >> ~/.bash_profile
like image 2
Dvid Silva Avatar answered Oct 18 '22 11:10

Dvid Silva