网上找了个很多的Homebrew的安装方法,有使用官网命令的有使用修改镜像源的,但都会遇到各种各样的问题,会被墙显示443,会显示路径不对,以下用的另一种方式全部在终端进行命令行模式安装,好处是不会被墙,大家可以试一下
1、先创建Homebrew目录
sudo mkdir /usr/local/Homebrew
2、执行clone
sudo git clone https://mirrors.ustc.edu.cn/brew.git /usr/local/Homebrew
3、创建brew指令软连接
sudo ln -s /usr/local/Homebrew/bin/brew /usr/local/bin/brew
4、创建目录存放core
sudo mkdir -p /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core
5、执行clone
sudo git clone https://mirrors.ustc.edu.cn/homebrew-core.git /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core
6、更改Homebrew的属主
sudo chown -R $(whoami) /usr/local/Homebrew
7、创建其它需要的目录
sudo mkdir -p /usr/local/Cellar /usr/local/Frameworks /usr/local/etc /usr/local/include /usr/local/lib /usr/local/opt /usr/local/sbin /usr/local/share /usr/local/var/homebrew/linked
8、为新创建的目录更改属主
sudo chown -R $(whoami) /usr/local/Cellar /usr/local/Frameworks /usr/local/etc /usr/local/include /usr/local/lib /usr/local/opt /usr/local/sbin /usr/local/share /usr/local/var/homebrew/linked
9、到这里,brew的安装就已经完成了,下面执行更新&检测
1、brew update
2、brew doctor
10、尝试安装一个nginx并启动它
1、brew install nginx
2、brew services start nginx
打开浏览器,输入地址 localhost:8080,就可以看到nginx已经安装成功并正常运行了。
网友评论