nginx進程屬主問題討論


   文章作者:luxianghao

   文章來源:http://www.cnblogs.com/luxianghao/p/6107096.html 轉載請注明,謝謝合作。

   免責聲明:文章內容僅代表個人觀點,如有不當,歡迎指正。

   --- 

近來由於工作需求,和nginx接觸較多,現把關於nginx進程屬主的問題總結如下:

規則
nginx啟動進程可以在conf里指定user(user  work;)但是這個只有在用root啟動的情況有意義,
如果是用其他用戶啟動的nginx master是沒有意義的 nginx會忽略這個配置,如下nginx warning所述
nginx: [warn] the "user" directive makes sense only if the master process runs with super-user privileges, ignored in /home/work/app/nginx/conf/nginx.conf:1
 
結論
1,在非root賬戶下啟動時,nignx的master和worker進程的owner都將是這個賬戶,
2,在root賬戶下啟動時 nignx的master進程是的owner是root,worker的owner在conf已配置用戶的情況下,owner是配置的用戶,否則將是nobody,而且也可能導致nginx的一些文件的owner也是nobody
 
# ps -ef | grep nginx
work     26620 21666  0 19:18 pts/5    00:00:00 vim conf/nginx.conf
root     26901     1  0 19:19 ?        00:00:00 nginx: master process ./sbin/nginx
nobody   26902 26901  0 19:19 ?        00:00:00 nginx: worker process
nobody   26903 26901  0 19:19 ?        00:00:00 nginx: worker process
nobody   26904 26901  0 19:19 ?        00:00:00 nginx: worker process
nobody   26905 26901  0 19:19 ?        00:00:00 nginx: worker process
nobody   26906 26901  0 19:19 ?        00:00:00 nginx: worker process
nobody   26910 26901  0 19:19 ?        00:00:00 nginx: cache manager process
nobody   26911 26901  0 19:19 ?        00:00:00 nginx: cache loader process
root     26918 24078  0 19:19 pts/11   00:00:00 grep nginx
 
# ll
total 72
drwxrwxr-x 7 work   work 4096 Jul 15 11:55 _book
drwxr-xr-x 2 nobody work 4096 Jul 15 11:55 cache
drwx------ 2 nobody work 4096 Jul 15 11:55 client_body_temp
drwxrwxr-x 2 work   work 4096 Nov 27 19:18 conf
drwx------ 2 nobody work 4096 Jul 15 11:55 fastcgi_temp
drwxrwxr-x 2 work   work 4096 Jul 15 11:55 html
drwx------ 2 nobody work 4096 Jul 15 11:55 uwsgi_temp


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM