一.问题

在使用Homebrew安装nginx时,会遇见如下错误:

1
2
3
    ksnowlv@ksnowlvdeMacBook-Pro~/Movies/PHP$brew install nginx
    Error: You must `brew link pcre' before nginx can be installed
    ksnowlv@ksnowlvdeMacBook-Pro~/Movies/PHP$

二.解决方案

可使用命令brew link --overwrite pcre,强制链接并覆盖冲突的文件即可。

1
2
3
   ksnowlv@ksnowlvdeMacBook-Pro~/Movies/PHP$brew link --overwrite pcre
    Linking /usr/local/Cellar/pcre/8.35... 133 symlinks created
    ksnowlv@ksnowlvdeMacBook-Pro~/Movies/PHP$brew install nginx

如果使用上述命令出错,则找到/usr/local/Cellar/pcre/usr/local/opt/pcrepcre目录干掉,重新安装pcre,再强制链接。