Updating php version on mac

2020-02-10 14:43发布

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.

标签: php macos
6条回答
迷人小祖宗
2楼-- · 2020-02-10 15:15

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
查看更多
▲ chillily
3楼-- · 2020-02-10 15:16

You can brew upgrade php7 or brew uninstall old php version.

Last, I recommend you brew install php-version, php-version can help you change your php version

查看更多
Rolldiameter
4楼-- · 2020-02-10 15:18

try to use the command, its working fine with me

curl -s https://php-osx.liip.ch/install.sh | bash -s 7.3
查看更多
仙女界的扛把子
5楼-- · 2020-02-10 15:32

Install php

brew install php@7.2

Install the required PHP to your PATH

echo 'export PATH="/usr/local/opt/php@7.2/bin:$PATH"' >> ~/.bash_profile
echo 'export PATH="/usr/local/opt/php@7.2/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
查看更多
Root(大扎)
6楼-- · 2020-02-10 15:35

Try to use below command

brew update brew install php@72

If it shows below error,

"Error: No available formula with the name "php"

try

brew install php@7.2

查看更多
Bombasti
7楼-- · 2020-02-10 15:36

The simplest way to update the version of php on Mac is via Homebrew.

If you do not have brew please visit https://brew.sh/ or install via command in terminal:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

When finished installing Homebrew, run the following commands:

brew update && brew upgrade
brew tap homebrew/dupes
brew tap homebrew/versions
brew tap homebrew/homebrew-php
brew unlink php@56  
brew install php@71

You might get an error if PHP 5.6 has not been installed by brew previously, but don't worry, you can simply continue.

You can also change the version to 7.0 by replacing the command from above commands from brew install php@71 to brew install php@70.

You can check the output by command.

php -v

If the output of php -v still doesn’t echoes the version 7, simply type this command and hit enter in terminal.

export PATH=/usr/local/php5/bin:$PATH
查看更多
登录 后发表回答