1. 程式人生 > >如何升級MacOS自帶的PHP到指定版本(5.3-7.3)

如何升級MacOS自帶的PHP到指定版本(5.3-7.3)

One Line Installation(一行安裝)

你所需要做的,只是開啟一個shell視窗(terminal),然後根據版本輸入以下命令:
(更新於2018-11-14)

PHP 7.3 (Next stable) - 10.10 and later

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

PHP 7.2 (Current stable) - 10.10 and later

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

PHP 7.1 (Old stable) - 10.10 and later

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

PHP 7.0 (Old stable) - 10.10 and later

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

PHP 5.6 (Old stable) - 10.8 and later

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

PHP 5.5 (End of life) - All OS X versions

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

PHP 5.4 (End of life) - All OS X versions

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

PHP 5.3 (End of life) - All OS X versions

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

我們會把包安裝到/usr/local/packer下,然後PHP會安裝到/usr/local/php5

FAQ

問什麼使用php -v命令會顯示舊版本的資訊?

php-osx不會覆蓋到Mac自帶的PHP binaries上,但是會安裝到/usr/local/php5

上,新的binary包會裝在 /usr/local/php5/bin/php上。
不過你可以設定PATH,修改~/.profile:
export PATH=/usr/local/php5/bin:$PATH

為什麼時區不對?為什麼我的配置檔案不生效?

參見/usr/local/php5/php.d/99-liip-developer.ini