How do I start nginx on port 80 at OS X login?
Posted
by
Bryson
on Super User
See other posts from Super User
or by Bryson
Published on 2011-06-30T00:10:50Z
Indexed on
2011/06/30
0:24 UTC
Read the original article
Hit count: 743
I installed Nginx using homebrew and after completing the installation the following message was displayed:
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 #{prefix}/org.nginx.nginx.plist ~/Library/LaunchAgents/
launchctl load -w ~/Library/LaunchAgents/org.nginx.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.)
But I want Nginx, on port 80, running at login and I don't want to have to open terminal and type in sudo nginx
to do it. I want it to load from a plist file like Redis and PostgreSQL do.
I moved the plist to /Library/LaunchAgents/
from the user folder equivalent and changed its ownership, also tried setting the user
directive in the nginx.conf
file and still the same error message in Console.app:
nginx: [emerg] bind() to 0.0.0.0:80 failed (13: Permission denied)
(along with another message telling me that since nginx
was being run without super-user privileges, the user
directive was being ignored)
© Super User or respective owner