homebrew的安装和使用

背景

最近用brew安装php总报错,缺少 icu4c

macos使用brew安装php后,老版本提示‘/usr/local/opt/icu4c/lib/libicui18n.70.dylib‘ (no such file)

/usr/local/opt/php@7.2/bin/php -v                
dyld[49280]: Library not loaded: '/usr/local/opt/icu4c/lib/libicui18n.70.dylib'
  Referenced from: '/usr/local/Cellar/php@7.2/7.2.34_4/bin/php'
  Reason: tried: '/usr/local/opt/icu4c/lib/libicui18n.70.dylib' (no such file), '/usr/local/lib/libicui18n.70.dylib' (no such file), '/usr/lib/libicui18n.70.dylib' (no such file), '/usr/local/Cellar/icu4c/72.1/lib/libicui18n.70.dylib' (no such file), '/usr/local/lib/libicui18n.70.dylib' (no such file), '/usr/lib/libicui18n.70.dylib' (no such file)
[1]    49280 abort      /usr/local/opt/php@7.2/bin/php -v

分析原因,brew的安装源的问题,解决方法,重新安装brew,并修改下载源为国内源

安装xcode

自己百度

安装homebrew

这可以说是网上所有brew教程中安装最快最省事的教程
安装命令如下:

/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"

复制终端回车即可

有关报错解决

  1. 错误1:

Cloning into '/usr/local/Homebrew'...
fatal: Unable to read current working directory: No such file or directory

有代理代理关了 删除之前的brew重新安装

  1. 安装php报错

brew安装报错 “cp: utimes: /usr/local/Cellar/jemalloc/.: Operation not permitted cp: chmod: /usr/local/C”

cp: utimes: /usr/local/Cellar/jemalloc/.: Operation not permitted 
cp: chmod: /usr/local/Cellar/jemalloc/.: Operation not permitted

解决办法:

sudo chown -R $(whoami) /usr/local/Cellar

  1. 权限文件
Error: Permission denied @ rb_sysopen - /usr/local/etc/openssl@1.1/ct_log_list.cnf

解决办法:

sudo chown -R 777 /usr/local/etc/openssl@1.1/ct_log_list.cnf

更多常见错误
https://gitee.com/cunkai/HomebrewCN/blob/master/error.md

卸载脚本

/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/HomebrewUninstall.sh)"

homebrew软件搜索

brew 常用命令

brew config
brew doctor                        #自检
brew update                        #更新brew可安装包,建议每次执行一下
brew search php55                  #搜索php5.5
brew tap josegonzalez/php          #安装扩展<gihhub_user/repo>   
brew tap                           #查看安装的扩展列表
brew install php55                 #安装php5.5
brew remove  php55                 #卸载php5.5
brew upgrade php55                 #升级php5.5
brew options php55                 #查看php5.5安装选项
brew info    php55                 #查看php5.5相关信息
brew home    php55                 #访问php5.5官方网站
brew services list                 #查看系统通过 brew 安装的服务
brew services cleanup              #清除已卸载无用的启动配置文件
brew services restart php55        #重启php-fpm
brew services  查看常用服务

brew redis安装

https://zhuanlan.zhihu.com/p/639711659

brew install redis
brew services start redis
brew services stop redis
/opt/homebrew/opt/redis/bin/redis-server /opt/homebrew/etc/redis.conf

PhpWebStudy安装

官网:
https://www.phpwebstudy.com/download.html
https://github.com/xpf0000/PhpWebStudy/releases/tag/v2.4.2

PhpWebStudy区分Apple Silicon和Intel X86, 带arm64的是Apple Silicon版, 不带的是Intel X86版, 请注意不要下载错了

image

从上图可看到,本人当前系统是 Intel X86 ,大家下载自己系统对应安装包版本即可.
这里我下载 PhpWebStudy-2.4.2-mac.zip

image

解压即可使用
image

安装php

  1. 双击打开 PhpWebStudy

  2. php->版本管理->安装需要的php版本

image

  1. 管理php
    php->服务 可管理已经安装的php启动,停止,设置为全局

image
image

  1. 查看php版本

php -v

posted @ 2024-04-22 09:20  HaimaBlog  阅读(165)  评论(0编辑  收藏  举报