8

そうです

$ brew install nginx

そして取得:

==> Downloading http://nginx.org/download/nginx-1.2.2.tar.gz
Already downloaded: /Library/Caches/Homebrew/nginx-1.2.2.tar.gz
==> Patching
patching file conf/nginx.conf
==> ./configure --prefix=/usr/local/Cellar/nginx/1.2.2 --with-http_ssl_module --with-pcre         --with-ipv6 --with-cc-opt=-I/usr/local/include --with-ld-opt=-L/usr/local/lib --conf
==> make
==> make install
==> Caveats
In the interest of allowing you to run `nginx` without `sudo`, the default
port is set to localhost:8080.

If you want to host pages on your local machine to the public, you should 
change that to localhost:80, and run `sudo nginx`. You'll need to turn off
any other web servers running port 80, of course.

You can start nginx automatically on login running as your user with:
mkdir -p ~/Library/LaunchAgents
cp /usr/local/Cellar/nginx/1.2.2/homebrew.mxcl.nginx.plist ~/Library/LaunchAgents/
launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.nginx.plist

Though note that if running as your user, the launch agent will fail if you
try to use a port below 1024 (such as http's default of 80.)
Warning: /usr/local/sbin is not in your PATH
You can amend this by altering your ~/.bashrc file 

私はこれを〜/.bashrcファイルに持っています:

 export PATH=$PATH:/usr/local/sbin

nginx-vまたはsudonginx-tiを実行すると、次のようになります。

-bash: nginx: command not found

nginxを正しくインストールしていませんか?

4

3 に答える 3

7

echo $ PATHを実行すると、/ usr / local / sbinが表示されますか?そうでない場合:〜/ .bashrcファイルを入手して、表示されるかどうかを確認します:source〜/ .bashrc

echo$PATHを再度実行します。表示されるはずです。

于 2012-10-03T17:34:09.370 に答える
1

私はbrewHomeでnginxをインストールしただけで、パス/usr/local/Cellar/nginx/1.12.0/binexport PATH=$PATH:/usr/local/Cellar/nginx/1.12.0/bin.

ご参考までに

于 2017-05-08T08:26:44.840 に答える
0

私のdebian6サーバーでは、nginxはにインストールされてい/usr/sbin/ます。ターミナルから直接アクセスする場合は、そのディレクトリをPATH変数に追加します。

PATH=/usr/sbin/:$PATH

sbinディレクトリは通常、rootユーザーのPATHに追加されますが、ターミナルにrootとしてログインしていますか?そうでない場合は、suコマンドを入力してください。

于 2012-10-03T17:03:29.790 に答える