查看可按照版本:
brew search php
使用brew安装:
brew install php@7.4
但报错:Error: php@7.4 has been disabled because it is a versioned formula!
这是因为php7.4官方已经不再维护,所以Hombrew将该php版本移出了repository,所以安装不了。
解决方案从第三方仓库中安装 比如(所有旧版php仓库地址https://github.com/shivammath…)
//将第三方仓库加入brewbrew tap shivammathur/php
//安装PHPbrew install shivammathur/php/php@7.4
2、替换Mac自带PHP环境并刷新环境变量
Linking /usr/local/Cellar/php@7.4/7.4.29.reinstall... 25 symlinks created.
If you need to have this software first in your PATH instead consider running:
echo 'export PATH="/usr/local/opt/php@7.4/bin:$PATH"' >> ~/.zshrc
echo 'export PATH="/usr/local/opt/php@7.4/sbin:$PATH"' >> ~/.zshrc ```
3、执行配置
echo ‘export PATH=“/usr/local/opt/php@7.4/bin:
P
A
T
H
"
′
>
>
/
.
z
s
h
r
c
e
c
h
o
′
e
x
p
o
r
t
P
A
T
H
=
"
/
u
s
r
/
l
o
c
a
l
/
o
p
t
/
p
h
p
@
7.4
/
s
b
i
n
:
PATH"' >> ~/.zshrc echo 'export PATH="/usr/local/opt/php@7.4/sbin:
PATH"′>> /.zshrcecho′exportPATH="/usr/local/opt/php@7.4/sbin:PATH”’ >> ~/.zshrc
``
4、刷新环境变量source ~/.zshrc
文章来源:https://www.toymoban.com/news/detail-689096.html
5、 输出php版本文章来源地址https://www.toymoban.com/news/detail-689096.html
PHP 7.4.29 (cli) (built: Apr 14 2022 11:48:33) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies ```
到了这里,关于mac brew 安装php7.4的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!