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?
-
Ubuntu is not a Unix.– RecursionSep 8, 2010 at 7:35
-
1@Recursion: Merely a technicality. All it lacks is the certification.– Ignacio Vazquez-AbramsSep 8, 2010 at 9:33
3 Answers
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.
Perhaps, suexec (switch user exec), is what you are looking for.
ubuntu doc http://manpages.ubuntu.com/manpages/lucid/man8/suexec.8.html