我做
$ 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吗?
答案 0 :(得分:7)
运行echo $ PATH,/ usr / local / sbin会出现吗? 如果不: 尝试获取〜/ .bashrc文件并查看它是否出现:source~ / .bashrc
再次运行echo $ PATH。它应该是apear。
答案 1 :(得分:0)
在我的debian 6服务器中,nginx安装在/usr/sbin/
中。如果要直接从终端访问它,请将该目录添加到PATH变量中:
PATH=/usr/sbin/:$PATH
sbin
目录通常会添加到root用户的PATH中,您是否以root身份登录终端?如果没有,您可以输入su
命令。