Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question
    
Ubuntu is not a Unix. –  Recursion Sep 8 '10 at 7:35
1  
@Recursion: Merely a technicality. All it lacks is the certification. –  Ignacio Vazquez-Abrams Sep 8 '10 at 9:33
    
Thanks for your help @Recursion... –  Joseph Silvashy Sep 9 '10 at 3:25
add comment

3 Answers 3

up vote 2 down vote accepted

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.

share|improve this answer
add comment

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

share|improve this answer
add comment

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

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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