mac通过Home-brew安装PHP(新)

1 首先安装homebrew,安装过的话更新

安装:homebrew官网地址:https://brew.sh/index_zh-cn.html。或者直接复制下面代码:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

更新:

brew update

或者使用brew doctor检测是否存在冲突(推荐)

brew update && brew upgrade brew doctor

2 添加第三方仓库

先执行下面命令查看都有哪些仓库

brew tap

然后添加仓库

brew tap homebrew/core

brew tap josegonzalez/php

3 安装PHP

先查看PHP

brew search php

安装PHP(以PHP7.1版本为例)

brew install [email protected]

 将PHP加入PATH

sudo vim ~/.bash_profile 
   
export PATH="$(brew --prefix [email protected])/bin:$PATH"

source ~/.bash_profile

加入launchctl控制启动 

mkdir -p ~/Library/LaunchAgents
cp /usr/local/opt/[email protected]/[email protected] ~/Library/LaunchAgents/
launchctl load -w ~/Library/LaunchAgents/[email protected]

 

转载于:https://www.cnblogs.com/jingxiaoniu/p/11102255.html

你可能感兴趣的:(mac通过Home-brew安装PHP(新))