首页 > 解决方案 > 为 mac 安装特定的 PHP 版本

问题描述

我需要一个特定版本的 PHP for magento (7.1.3)

使用 home brew 或 curl,我只能指定一位小数(7.1、7.2 等)。

跑步

brew install php@7.1

最终得到我

php -v
PHP 7.1.29 (cli) (built: May 21 2019 20:05:17) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.1.29, Copyright (c) 1999-2018, by Zend 
Technologies

尝试安装特定版本(就像您可以使用 nvm 使用节点一样):

brew install php@7.1.3

得到我

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

我尝试使用 curl 命令,同样的问题:

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

得到我

Did or could not download package: 7.1.3-frontenddev

TL;DR:我如何在 mac 上安装 PHP (7.1.3) 的确切版本?

标签: phpmacosapachemagento2

解决方案


对于 brew 中已弃用的 php 版本。请运行这个。

brew tap exolnet/homebrew-deprecated

然后选择你的版本。

brew install php@7.1

切换回第一个 PHP 版本。

brew link --force --overwrite php@7.1

这里是参考,

macOS 10.15 Catalina Apache 设置:多个 PHP 版本


推荐阅读