安装PHP7.2+ 操作步骤 安装HomeBrew /bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)" 使用B
操作步骤
/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"
brew install php@7.2 // Error: php@7.2 has been disabled because it is deprecated upstream! // 提示官方已不再维护
// 将第三方仓库加入brewbrew tap shivammathur/php// 安装PHPbrew install shivammathur/php/php@7.2
~/
,修改 .bash_profile
文件export LDFLAGS="-L/usr/local/opt/php@7.2/lib"export CPPFLAGS="-I/usr/local/opt/php@7.2/include"
~/
,修改 . zshrc
文件source ~/.bash_profile
brew link --overwrite php@7.2
brew services restart php
php -V
修改文件 /usr/local/etc/php/7.2/php-fpm.conf,去掉第17行、24行前面分号
其他说明
composer.phar
文件到 /usr/local/bin
下:打开终端 执行命令 mv composer.phar /usr/local/bin/composer
chmod +x /usr/local/bin/composer
composer
---
### 安装多个版本php --2023.01.14 更新
#### 操作步骤
1. 查看仓库 `brew search php`
![](Https://img2023.cnblogs.com/blog/529800/202301/529800-20230114162633890-18915096.png)
安装php5.6
`brew install shivammathur/php/php@5.6`
添加PHP环境变量
```
# 终端
vim ~/.bash_profile
# 新增
export PATH="/opt/homebrew/opt/php@5.6/bin:$PATH"
export PATH="/opt/homebrew/opt/php@5.6/sbin:$PATH"
# 终端 刷新 ~/.bash_profile
source ~/.bash_profile
```
安装PHP版本切换工具 brew-php-swither
```
brew install brew-php-switcher
```
切换和使用不同版本php
```
# 切换版本
brew-php-switcher 5.6
brew-php-switcher 7.2
php -v
# 其他命令
brew services start php@5.6 # 启动 php5.6
brew services stop php@5.6 #关闭 php5.6
```
来源地址:https://blog.csdn.net/u010108836/article/details/128131762
--结束END--
本文标题: Mac 安装php7.2+和composer
本文链接: https://lsjlt.com/news/399566.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0