Running nginx as another user

I followed the guide in the linode library for Debian 5 with nginx and passenger. The init.d script was very nice, but it runs nginx as root. I want to run it as www-data, so I added -c www-data to the start-stop-daemon options. However, I'm getting this error when I try and start nginx:

Starting nginx: [emerg]: bind() to 0.0.0.0:80 failed (13: Permission denied)

Seems www-data doesn't have permissions to listen on port 80. How can I fix this?

2 Replies

Only root can bind to ports under 1024. For this reason, most daemons are run as root and then change user to a non-privileged user.

The correct way to get a daemon to run as a regular user, then, is to use the configuration system provided by that daemon.

In nginx's case, there appears to be a "user" parameter at the start of its configuration file.

Ah, I see. Thanks, that did the job. :)

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct