0

I'm told I should run my Rails app as the user www-data, how do I do that? How can I also run say Nginx, and other services as certain users? What is the best practice for this?

2
  • Ubuntu is not a Unix.
    – Recursion
    Sep 8, 2010 at 7:35
  • 1
    @Recursion: Merely a technicality. All it lacks is the certification. Sep 8, 2010 at 9:33

3 Answers 3

2

Many programs, particularly those intended to be run as daemons, will have a command line flag for which user to run as. These are particularly important for applications which expect to use 'privileged' ports -- under 1024 -- as only root can open listen sockets there. Most such apps will start as root, read the configs, open sockets, then setuid() to a restricted user.

Other programs -- mainly ones that don't need low-numbered ports -- can just be run via an 'su' call in their startup script.

1

The sudo command also does that; checkout its man page.

0

Perhaps, suexec (switch user exec), is what you are looking for.

ubuntu doc http://manpages.ubuntu.com/manpages/lucid/man8/suexec.8.html

apache doc http://httpd.apache.org/docs/current/suexec.html

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .