mac brew 安装php7.4

查看可按照版本:

brew search php

使用brew安装:

brew install [email protected]

但报错:
Error: [email protected] has been disabled because it is a versioned formula!
这是因为php7.4官方已经不再维护,所以Hombrew将该php版本移出了repository,所以安装不了。

解决方案
从第三方仓库中安装 比如(所有旧版php仓库地址https://github.com/shivammath…)
//将第三方仓库加入brew
brew tap shivammathur/php
//安装PHP
brew install shivammathur/php/[email protected]

2、替换Mac自带PHP环境并刷新环境变量

Linking /usr/local/Cellar/[email protected]/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/[email protected]/bin:$PATH"' >> ~/.zshrc
 echo 'export PATH="/usr/local/opt/[email protected]/sbin:$PATH"' >> ~/.zshrc ```
 
3、执行配置

echo ‘export PATH=“/usr/local/opt/[email protected]/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/[email protected]/sbin: PATH">> /.zshrcechoexportPATH="/usr/local/opt/php@7.4/sbin:PATH”’ >> ~/.zshrc
``

4、刷新环境变量
source ~/.zshrc

5、 输出php版本

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 ```



你可能感兴趣的:(开发工具,php基础,macos,php,服务器)