Mac 更新 PHP 版本

qqqqqqq7發表於2019-12-29

1.0 搜尋版本

$ brew search php

brew-php-switcher  php  php-code-sniffer php-cs-fixer php@7.2  php@7.3  phplint  phpmd  phpmyadmin phpstan  phpunit

2.0 選擇安裝的版本

$ brew install php@7.2
#waiting...

3.0 安裝路徑

$ /usr/local/opt/php@7.2

cd /usr/local/opt/php@7.2/bin/
./php -v

PHP 7.2.26 (cli) (built: Dec 18 2019 15:28:58) ( NTS )

Copyright (c) 1997-2018 The PHP Group

Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies

 with Zend OPcache v7.2.26, Copyright (c) 1999-2018, by Zend Technologies

4.0 修改php預設環境變數

#先檢視預設路徑
which php
#新建base_profile
$ vim ~/.bash_profile

5.0 新增路徑

export PATH="/usr/local/opt/php@7.2/bin:$PATH"
#儲存

6.0 執行檔案使配置生效

source ~/.bash_profile

php -v

PHP 7.2.26 (cli) (built: Dec 18 2019 15:28:58) ( NTS )

Copyright (c) 1997-2018 The PHP Group

Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies

 with Zend OPcache v7.2.26, Copyright (c) 1999-2018, by Zend Technologies

 #完成啦
本作品採用《CC 協議》,轉載必須註明作者和本文連結

相關文章