修改apache的默认用户和组
修改apache的默认用户和组##更改前查看apache的用户和组
egrep -i "user|group" httpd.conf |egrep -v "#|^$"
ps -ef |grep httpd
# egrep -i "user|group" httpd.conf |egrep -v "#|^$"
User daemon
Group daemon
# ps -ef |grep httpd
root 43329 10 11:09 ? 00:00:00 /application/apache/bin/httpd
daemon 43331 433290 11:09 ? 00:00:00 /application/apache/bin/httpd
daemon 43332 433290 11:09 ? 00:00:00 /application/apache/bin/httpd
daemon 43333 433290 11:09 ? 00:00:00 /application/apache/bin/httpd
daemon 43334 433290 11:09 ? 00:00:00 /application/apache/bin/httpd
root 4345539160 11:28 pts/1 00:00:00 grep httpd
#
#######################
创建用户和组
useradd -s /sbin/nologin -M apache
tail -1 /etc/passwd
###
# useradd -s /sbin/nologin -M apache
# tail -1 /etc/passwd
apache:x:502:502::/home/apache:/sbin/nologin
######更改apache的用户和组
egrep -i "user|group" httpd.conf |egrep -v "#|^$"
sed -i 's/User daemon/User apache/g' httpd.conf
sed -i 's/Group daemon/Group apache/g' httpd.conf
egrep -i "user|group" httpd.conf |egrep -v "#|^$"
###
# egrep -i "user|group" httpd.conf |egrep -v "#|^$"
User daemon
Group daemon
#
# sed -i 's/User daemon/User apache/g' httpd.conf
# sed -i 's/Group daemon/Group apache/g' httpd.conf
# egrep -i "user|group" httpd.conf |egrep -v "#|^$"
User apache
Group apache
#######重启apache测试是否更改成功
/application/apache/bin/apachectl graceful
ps -ef|grep http
###
# /application/apache/bin/apachectl graceful
# ps -ef|grep http
root 43329 10 11:09 ? 00:00:00 /application/apache/bin/httpd
apache 43480 433290 11:36 ? 00:00:00 /application/apache/bin/httpd
apache 43481 433290 11:36 ? 00:00:00 /application/apache/bin/httpd
apache 43482 433290 11:36 ? 00:00:00 /application/apache/bin/httpd
apache 43483 433290 11:36 ? 00:00:00 /application/apache/bin/httpd
root 4356639160 11:36 pts/1 00:00:00 grep http
#
全部命令
###查看是否存在apache用户,没就创建apache用户和组
cat /etc/passwd
useradd -s /sbin/nologin -M apache
tail -1 /etc/passwd
##查看现在的apache的用户和组是什么
ps -ef |grep httpd
cd /application/apache/conf/
egrep -i "user|group" httpd.conf |egrep -v "#|^$"
##更改apache的用户和组
sed -i 's/User daemon/User apache/g' httpd.conf
sed -i 's/Group daemon/Group apache/g' httpd.conf
egrep -i "user|group" httpd.conf |egrep -v "#|^$"
##重启看是否更改成功
/application/apache/bin/apachectl graceful
ps -ef|grep http
页:
[1]