HomeBrew安装软件报错Failed to connect to raw.githubusercontent.com port 443: Operation timed out
原因：raw.githubusercontent.com 无法访问通过该地址，查看可以访问的IP地址 site.ip138.com设置hostssudo vi /etc/hosts例如填入如下内容：182.43.124.6 raw.githubusercontent.com
前言MacOS可以使用launchctl命令管理服务，也可以使用brew services。brew services 相比 launchctl，操作更简化，更加类似 Centos 的 systemd 命令。brew services常用命令启动、停止服务例如：启动nginxbrew services start nginx例如：停止php-fpmbrew services stop php查看服务列表brew services list# 示例输出 Name Status User File nginx started dotatong ~/Library/LaunchAgents/homebrew.mxcl.nginx.plist php started dotatong ~/Library/LaunchAgents/homebrew.mxcl.php.plist清除无用服务配置brew services cleanuplaunchctl常用命令启动、停止服务例如：启动nginxlaunchctl start ~/Library/LaunchAgents/homebrew.mxcl.nginx.plist例如：停止php-fpmlaunchctl stop ~/Library/LaunchAgents/homebrew.mxcl.php.plist查看服务列表launchctl list开机启动启用开机启动launchctl enable ~/Library/LaunchAgents/homebrew.mxcl.nginx.plist禁用开机启动launchctl disable ~/Library/LaunchAgents/homebrew.mxcl.nginx.plist服务配置加载配置launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.nginx.plist注意：-w为可选参数，表示忽略配置文件中 Disabled 选项，都启动服务卸载配置launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.nginx.plist配置文件服务配置文件目录目录说明~/Library/LaunchAgents用户登录后自启动服务/Library/LaunchAgents用户登录后自启动服务（该目录需要root权限）/Library/LaunchDaemonsroot开机自启动服务（该目录需要root权限）/System/Library/LaunchDaemonsroot开机自启动服务（该目录需要root权限）/System/Library/LaunchAgents用户登录后自启动服务（该目录需要root权限）配置文件格式，例如：nginx配置文件<?xml version="1.0" encoding="UTF-8"?> Label homebrew.mxcl.nginx LimitLoadToSessionType Aqua Background LoginWindow StandardIO System ProgramArguments /usr/local/opt/nginx/bin/nginx -g daemon off; RunAtLoad <true/> WorkingDirectory /usr/local 配置文件中的项项说明Label服务名称Disabled是否禁用该服务KeepAlive挂掉后是否自动重启该服务ProgramArguments程序启动参数RunAtLoad是否开机启动UserName启动服务的用户GroupName启动服务的用户组
安装homebrew如果还未安装homebrew的话，使用以下命令安装/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"卸载命令/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/HomebrewUninstall.sh)"Step1：更换brew源查看cd "$(brew --repo)" && git remote -v更换git remote set-url origin https://mirrors.cloud.tencent.com/homebrew/brew.gitStep2：更换homebrew-core源(注意：brew v4 不需要此步)查看cd "$(brew --repo homebrew/core)" && git remote -v更换git remote set-url origin https://mirrors.cloud.tencent.com/homebrew/homebrew-core.gitStep3：更换homebrew-cask源(注意：brew v4 不需要此步)查看cd "$(brew --repo homebrew/cask)" && git remote -v更换git remote set-url origin https://mirrors.cloud.tencent.com/homebrew/homebrew-cask.gitStep4：添加环境变量在.bashrc或.zshrc中设置环境变量export HOMEBREW_NO_AUTO_UPDATE=1 export HOMEBREW_PIP_INDEX_URL=https://mirrors.cloud.tencent.com/pypi/simple export HOMEBREW_API_DOMAIN=https://mirrors.cloud.tencent.com/homebrew-bottles/api export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.cloud.tencent.com/homebrew-bottles常用命令#查看已安装的包 brew list #查看服务列表 brew services list #启动、停止、重启、热重载服务 brew services start 服务名 brew services stop 服务名 brew services restart 服务名 brew services reload 服务名 #以树形结构显示已安装包的依赖关系 brew deps --installed --tree