Mac OS X 10.10 下安裝Nginx, 終端紀錄如下:
Installing nginx
==> Downloading https://homebrew.bintray.com/bottles/nginx-1.8.0.yosemite.bottle.tar.gz
######################################################################## 100.0%
==> Pouring nginx-1.8.0.yosemite.bottle.tar.gz
==> Caveats
Docroot is: /usr/local/var/www
The default port has been set in /usr/local/etc/nginx/nginx.conf to 8080 so that
nginx can run without sudo.
nginx will load all files in /usr/local/etc/nginx/servers/.
To have launchd start nginx at login:
ln -sfv /usr/local/opt/nginx/*.plist ~/Library/LaunchAgents
Then to load nginx now:
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.nginx.plist
Or, if you don`t want/need launchctl, you can just run:
nginx
==> Summary
執行nginx
,報錯:
nginx
dyld: Library not loaded: /usr/local/lib/libpcre.1.dylib
Referenced from: /usr/local/bin/nginx
Reason: image not found
[1] 954 trace trap nginx
通過brew doctor
看看到底是哪裡出了問題:
brew doctor
獲得如下資訊:
Warning: You have unlinked kegs in your Cellar
Leaving kegs unlinked can lead to build-trouble and cause brews that depend on
those kegs to fail to run properly once built. Run `brew link` on these:
pcre
按照提示操作,結果又丟擲一條錯誤:
brew link pcre
Linking /usr/local/Cellar/pcre/8.36...
Error: Could not symlink share/man/man3/pcre.3
/usr/local/share/man/man3 is not writable.
Google一下,發現一個解決方案
sudo chown -R mcbird /usr/local/share/man/man3
接著,再link
操作即可:
brew link pcre
完成後,就可以成功執行nginx
了。