8

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:

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

When I run nginx -v or sudo nginx -t i get this:

-bash: nginx: command not found

have I not installed nginx properly?

6
  • When you run echo $PATH, does /usr/local/sbin appear? Oct 3, 2012 at 17:00
  • Try sourcing your ~/.bashrc file and see if it appears: source ~/.bashrc. Oct 3, 2012 at 17:11
  • Nothing should appear, but your $PATH variable should be updated. Try echo $PATH again =) . If it didn't work, there might be a problem with your .bashrc Oct 3, 2012 at 17:18
  • This was appended to what I received previously :/Users/macuser/usr/local/sbin:/Users/macuser/.rvm/bin:/Users/macuser/usr/local/sbin
    – Benamir
    Oct 3, 2012 at 17:21
  • I find it weird that it's prepending '/Users/macuser' to the path you're trying to export. Maybe that's the problem, but I don't know how to help you =( Oct 3, 2012 at 17:24

3 Answers 3

7

run echo $PATH, does /usr/local/sbin appear? if not: Try sourcing your ~/.bashrc file and see if it appears: source ~/.bashrc

run echo $PATH again. It should apear.

1

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/bin to the conf file, and it works well.

FYI

0

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:

PATH=/usr/sbin/:$PATH

The sbin directories 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 su command.

1
  • 2
    If installed by Homebrew, it'll be in /usr/local/sbin.
    – mipadi
    Oct 4, 2012 at 6:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.