bash 未找到 NGINX brew install 命令
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12713233/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
NGINX brew install command not found
提问by Benamir
I do
我愿意
$ brew install nginx
and get:
并得到:
==> 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
I have this in my ~/.bashrc file:
我的 ~/.bashrc 文件中有这个:
export PATH=$PATH:/usr/local/sbin
When I run nginx -v or sudo nginx -t i get this:
当我运行 nginx -v 或 sudo nginx -ti 时,得到这个:
-bash: nginx: command not found
have I not installed nginx properly?
我没有正确安装nginx吗?
采纳答案by Benamir
run echo $PATH, does /usr/local/sbin appear? if not: Try sourcing your ~/.bashrc file and see if it appears: source ~/.bashrc
运行 echo $PATH,是否出现 /usr/local/sbin?如果没有:尝试获取你的 ~/.bashrc 文件,看看它是否出现: source ~/.bashrc
run echo $PATH again. It should apear.
再次运行 echo $PATH 。它应该出现。
回答by hanzichi
I just install nginx by brewHome, and I find the path is /usr/local/Cellar/nginx/1.12.0/bin, so I just add export PATH=$PATH:/usr/local/Cellar/nginx/1.12.0/binto the conf file, and it works well.
我就是用brewHome安装nginx的,发现路径是. /usr/local/Cellar/nginx/1.12.0/bin,所以就export PATH=$PATH:/usr/local/Cellar/nginx/1.12.0/bin加到conf文件中,效果很好。
FYI
供参考
回答by Nelson
In my debian 6 server nginx is installed in /usr/sbin/. If you want to access it directly from terminal add that directory to your PATH variable:
在我的 debian 6 服务器中,nginx 安装在/usr/sbin/. 如果您想直接从终端访问它,请将该目录添加到您的 PATH 变量中:
PATH=/usr/sbin/:$PATH
The sbindirectories are commonly added to PATH for the root user, are you logged in the terminal as root ? If not you can do so by entering sucommand.
这些sbin目录通常添加到 root 用户的 PATH 中,您是否以 root 身份登录终端?如果没有,您可以通过输入su命令来执行此操作。

