【问题标题】:NGINX brew install command not found未找到 NGINX brew install 命令
【发布时间】:2012-10-03 16:56:13
【问题描述】:

我愿意

$ 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 或 sudo nginx -t 我得到这个:

-bash: nginx: command not found

我没有正确安装 nginx 吗?

【问题讨论】:

  • 运行echo $PATH时,会出现/usr/local/sbin吗?
  • 尝试获取您的 ~/.bashrc 文件,看看它是否出现:source ~/.bashrc
  • 什么都不会出现,但是你的 $PATH 变量应该被更新了。再次尝试echo $PATH =) 。如果它不起作用,那么您的 .bashrc 可能有问题
  • 这是附加到我之前收到的内容:/Users/macuser/usr/local/sbin:/Users/macuser/.rvm/bin:/Users/macuser/usr/local/sbin跨度>
  • 我觉得奇怪的是,它在您尝试导出的路径之前添加了“/Users/macuser”。也许这就是问题所在,但我不知道如何帮助你=(

标签: bash command-line nginx homebrew .bash-profile


【解决方案1】:

运行 echo $PATH,会出现 /usr/local/sbin 吗? 如果不: 尝试获取您的 ~/.bashrc 文件,看看它是否出现:source ~/.bashrc

再次运行 echo $PATH。它应该出现。

【讨论】:

    【解决方案2】:

    我只是通过brewHome安装nginx,发现路径是/usr/local/Cellar/nginx/1.12.0/bin,所以我只是在conf文件中添加export PATH=$PATH:/usr/local/Cellar/nginx/1.12.0/bin,就可以了。

    仅供参考

    【讨论】:

      【解决方案3】:

      在我的 debian 6 服务器中,nginx 安装在 /usr/sbin/ 中。如果您想直接从终端访问它,请将该目录添加到您的 PATH 变量中:

      PATH=/usr/sbin/:$PATH
      

      sbin 目录通常添加到 root 用户的 PATH 中,您是否以 root 身份登录终端?如果没有,您可以通过输入su 命令来执行此操作。

      【讨论】:

      • 如果由 Homebrew 安装,它将位于 /usr/local/sbin
      猜你喜欢
      • 2016-02-08
      • 2019-02-08
      • 2020-12-05
      • 2017-01-19
      • 2018-03-18
      • 2015-07-24
      • 2022-01-05
      • 2012-12-26
      • 1970-01-01
      相关资源
      最近更新 更多