近日,從新整理了下開發環境,重裝了,nginx,可是這個時候倒是報錯了,報錯信息以下:php
[root@hserver1 php-7.0.5]# nginx -t nginx: [emerg] getpwnam("nginx") failed in /etc/nginx/nginx.conf:2 nginx: configuration file /etc/nginx/nginx.conf test failed
喏,很明顯了,缺乏用戶組信息,至於爲何會缺乏呢?暫時不清楚,若是有知道緣由的請評論區留言,萬分感謝。nginx
好了,既然缺乏用戶組,那麼咱們確定是要建立一個用戶組信息了:bash
建立用戶組;spa
[root@hserver1 php-7.0.5]# groupadd -f nginx groupadd: cannot open /etc/group
嗯?打不開?沒權限?經過用lsattr
命令查看/etc/group
的隱藏權限設定狀況發現以下:code
[root@hserver1 php-7.0.5]# lsattr /etc/group ----i----------- /etc/group
i 說明設定文件不能被刪除、更名、設定連接關係,同時不能寫入或新增內容。 用 chattr 命令對 /etc/group 去除 i 權限位。那怎麼辦呢?server
用 chattr 命令對 /etc/group 去除 i權限位:blog
[root@hserver1 php-7.0.5]# chattr -i /etc/group [root@hserver1 php-7.0.5]# lsattr /etc/group ---------------- /etc/group
去除了 i ,咱們再次添加:開發
[root@hserver1 php-7.0.5]# groupadd -f nginx groupadd: cannot open /etc/gshadow
似曾相識的一幕,好吧,重複上面的步驟,去除隱式權限 i位。因爲後面還有多種相似的狀況,如今咱們就直接寫出全部餘下的去除 i 位步驟吧。get
[root@hserver1 php-7.0.5]# chattr -i /etc/gshadow [root@hserver1 php-7.0.5]# chattr -i /etc/passwd [root@hserver1 php-7.0.5]# chattr -i /etc/shadow
最終,咱們建立用戶組以下:io
[root@hserver1 php-7.0.5]# groupadd -f nginx [root@hserver1 php-7.0.5]# useradd -g nginx nginx
OK,這下總算是成功了。