MAC安装homebrew、php及其扩展

homebrew

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

替换homebrew国内镜像源

brew install --cask dosbox
  • 替换源
git -C "$(brew --repo)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git

# 手动设置
git -C "$(brew --repo homebrew/core)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git
git -C "$(brew --repo homebrew/cask)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-cask.git
git -C "$(brew --repo homebrew/cask-fonts)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-cask-fonts.git
git -C "$(brew --repo homebrew/cask-drivers)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-cask-drivers.git
git -C "$(brew --repo homebrew/cask-versions)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-cask-versions.git
  • 复原源
# brew 程序本身,Homebrew / Linuxbrew 相同
git -C "$(brew --repo)" remote set-url origin https://github.com/Homebrew/brew.git

# 以下针对 macOS 系统上的 Homebrew
BREW_TAPS="$(brew tap)"
for tap in core cask{,-fonts,-drivers,-versions}; do
    if echo "$BREW_TAPS" | grep -qE "^homebrew/${tap}\$"; then
        git -C "$(brew --repo homebrew/${tap})" remote set-url origin https://github.com/Homebrew/homebrew-${tap}.git
    fi
done

安装php

  • 安装php
brew search php
brew install php@7.2

  • pecl安装扩展
pecl search redis
pecl install redis
pecl install swoole
# 安装指定包 http://pecl.php.net/package/swoole
pecl install http://pecl.php.net/get/swoole-4.6.1.tgz 

  • 安装PHP版本切换工具
brew install brew-php-switcher
brew install php@7.3
brew-php-switcher 7.3
  • 启动和停止php-fpm
brew services start php@7.2
brew services restart php@7.2
brew services stop php@7.2

编译安装php扩展

  • 例如安装 php trie-filter扩展
git clone https://github.com/zzjin/php-ext-trie-filter
cd php-ext-trie-filter/
/usr/local/bin/phpize
 # 如果php-config在$PATH下,可不用加--with-php-config,不在则指定
./configure  --with-php-config=/usr/local/bin/php-config
make
make install 
 # 添加扩展到php.ini
php -i|grep ini # 找到对应的php.ini地址 添加
vim php.ini
extension=trie_filter.so
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值