Error: Could not symlink share/man/man8/nginx.8

nginxをbrewでインストール

$ brew install nginx

nginxコマンドを打つとコマンドが見つからない

$ nginx
nginx: command not found

インストールはされているが, 有効化されていないとのこと

$ brew install nginx
Warning: nginx-1.8.0 already installed, it's just not linked

linkしてみるとエラーが発生

$ brew link nginx
Linking /usr/local/Cellar/nginx/1.8.0...
Error: Could not symlink share/man/man8/nginx.8
/usr/local/share/man/man8 is not writable.

じゃあ権限を与えてみる

$ sudo chown {user name} /usr/local/share/man/man8
Password:

再度linkを試すと成功した

$ brew link nginx
Linking /usr/local/Cellar/nginx/1.8.0... 2 symlinks created

nginxコマンドを打ってみるとこんなエラーが...

$ nginx
nginx: [emerg] bind() to 0.0.0.0:80 failed (13: Permission denied)

テストオプションをつけてみる

nginx -t
nginx: the configuration file /usr/local/etc/nginx/nginx.conf syntax is ok
nginx: [emerg] bind() to 0.0.0.0:80 failed (13: Permission denied)
nginx: configuration file /usr/local/etc/nginx/nginx.conf test failed

1024以下のポートを開放するにはルート権限が必要らしいので, sudoをつけてみる

$ sudo nginx -t
Password:
nginx: the configuration file /usr/local/etc/nginx/nginx.conf syntax is ok
nginx: configuration file /usr/local/etc/nginx/nginx.conf test is successful

テストは成功したみたいなので, sudoをつけて起動

$ sudo nginx

ブラウザで確認してみる