Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Updating php version on mac

Tags:

php

macos

I want to update php version, currently I have 5.5.38 and I want 7.1

What I tried so far is using this command:

curl -s https://php-osx.liip.ch/install.sh | bash -s 7.1 

I tried several different versions but none of them worked. It opens bash_profile for a second and then I get Received SIGHUP or SIGTERM and message below:

Buffer written to /Users/Morpheus/.bash_profile.save.6

Not sure what went wrong and why it won't update...

Any ideas?

Thanks.

like image 236
Morpheus Avatar asked Jan 26 '17 11:01

Morpheus


People also ask

How do I update my PHP version on Mac?

To update the PHP version, update the brew using the command brew update . Then, use the command brew upgrade php . It upgrades the current version to the latest version of PHP. Then, restart the webserver to see the changes.


2 Answers

Install php

brew install [email protected] 

Install the required PHP to your PATH

echo 'export PATH="/usr/local/opt/[email protected]/bin:$PATH"' >> ~/.bash_profile echo 'export PATH="/usr/local/opt/[email protected]/sbin:$PATH"' >> ~/.bash_profile source ~/.bash_profile 

Then make sure it's all working

php -v php --version 

This command will show you where your ini file is loaded

php --ini 
like image 178
matinict Avatar answered Oct 15 '22 01:10

matinict


Use Homebrew:

I would probably recommend installing homebrew to manage such installations for you. With that installed you can just run the following command to install php7.1

brew update brew install php@71 
like image 20
Viktor Avatar answered Oct 15 '22 01:10

Viktor