标签:更改apache用户和组
修改apache的默认用户和组
##更改前查看apache的用户和组
egrep -i "user|group" httpd.conf |egrep -v "#|^$"
ps -ef |grep httpd
[root@LAMP conf]# egrep -i "user|group" httpd.conf |egrep -v "#|^$"
User daemon
Group daemon
[root@LAMP lib]# ps -ef |grep httpd
root 43329 1 0 11:09 ? 00:00:00 /application/apache/bin/httpd
daemon 43331 43329 0 11:09 ? 00:00:00 /application/apache/bin/httpd
daemon 43332 43329 0 11:09 ? 00:00:00 /application/apache/bin/httpd
daemon 43333 43329 0 11:09 ? 00:00:00 /application/apache/bin/httpd
daemon 43334 43329 0 11:09 ? 00:00:00 /application/apache/bin/httpd
root 43455 3916 0 11:28 pts/1 00:00:00 grep httpd
[root@LAMP lib]#
#######################
创建用户和组
useradd -s /sbin/nologin -M apache
tail -1 /etc/passwd
###
[root@LAMP ~]# useradd -s /sbin/nologin -M apache
[root@LAMP ~]# 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 "#|^$"
###
[root@LAMP conf]# egrep -i "user|group" httpd.conf |egrep -v "#|^$"
User daemon
Group daemon
[root@LAMP conf]#
[root@LAMP conf]# sed -i ‘s/User daemon/User apache/g‘ httpd.conf
[root@LAMP conf]# sed -i ‘s/Group daemon/Group apache/g‘ httpd.conf
[root@LAMP conf]# egrep -i "user|group" httpd.conf |egrep -v "#|^$"
User apache
Group apache
#######重启apache测试是否更改成功
/application/apache/bin/apachectl graceful
ps -ef|grep http
###
[root@LAMP conf]# /application/apache/bin/apachectl graceful
[root@LAMP conf]# ps -ef|grep http
root 43329 1 0 11:09 ? 00:00:00 /application/apache/bin/httpd
apache 43480 43329 0 11:36 ? 00:00:00 /application/apache/bin/httpd
apache 43481 43329 0 11:36 ? 00:00:00 /application/apache/bin/httpd
apache 43482 43329 0 11:36 ? 00:00:00 /application/apache/bin/httpd
apache 43483 43329 0 11:36 ? 00:00:00 /application/apache/bin/httpd
root 43566 3916 0 11:36 pts/1 00:00:00 grep http
[root@LAMP conf]#
全部命令
###查看是否存在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
本文出自 “技术改变命运” 博客,请务必保留此出处http://lvnian.blog.51cto.com/7155281/1697764
标签:更改apache用户和组
原文地址:http://lvnian.blog.51cto.com/7155281/1697764