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

I noticed that nginx users tend to create a separate group and user for nginx. Why is this?

Further, the default path for the HTML public directory is /usr/local/nginx/html, but people use the home directory instead (e.g. /home/newuser/mysite.com/public). The same goes for log files and maybe some others. I suppose the reason is the same as for my previous question?

I'm basing this off a script called "centmin", mainly, but I've seen other resources follow the same trend.

share|improve this question

3 Answers 3

up vote 3 down vote accepted

Why this is, well, it's really not nginx specific, most every daemon gets its own uid/gid for security reasons. Whether you use a home dir or /usr is totally up to your choice, it more depends on the role of the machine -- with several users , each running from their home dir might make more sense, a dedicated machine might be better off from a system dir...

share|improve this answer
    
Thank you. I forgot to mention I'm still a Linux newbie. Could you elaborate on why it makes things more secure? Just for clarification, if I am running a VPS, would it make more sense to just use /usr? –  someguy May 7 '11 at 17:42
1  
@someguy: file and process permissions prevents daemons running under different users from accessing the files or processes of other daemons (and users of course). –  Lekensteyn May 7 '11 at 17:51

It's a Good Thing(TM) to have a daemon run on a dedicated unprivileged account. If the daemon ever gets exploited or turn rogue because of some bug, the damage will be limited to areas writeable by that user.

For discussion on placement of web root directory also take a look at /home/vhosts/ or /var/www/

share|improve this answer

Another reason for separation especially in Nginx auto installers like http://centminmod.com/ is that /home directory usually is the larger partitioned segment than /usr. And authors of such scripts don't know how end users partition their drives, they can't assume /usr has adequate disk free space. 99% of the time /home has the larger disk free space.

share|improve this answer

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.