apache2: bad user name ${APACHE_RUN_USER} 解决,树莓派raspberry Pi下的apache2也有这个问题,由apachectl来启动。

jackxiang 2015-5-12 23:42 | |
背景:用树莓派修改进程数后,想重启后出现问题及解决。

apache2: bad user name ${APACHE_RUN_USER} 解决

开工后,发现有个虚拟机的apache没起来,调用apache2 -k start 后,提示如下内容:

apache2: bad user name ${APACHE_RUN_USER}



apache 启动时,是由读取 /etc/apache2/apache2.conf 读取了运行 User

而运行的user环境变量定义在/etc/apache2/envvars

而不是使用默认的登录账户启动,因此apache提供了
apache2ctl 工具来使用,调用

apache2ctl -k start

即可
______________________________________________________________________________________

pkill -9 apache
/usr/sbin/apache2 -k start
apache2: bad user name ${APACHE_RUN_USER}
/usr/sbin/apachectl -k start
apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName
启动成功!


vi +178 /etc/apache2/apache2.conf
# These need to be set in /etc/apache2/envvars
User ${APACHE_RUN_USER}
Group ${APACHE_RUN_GROUP}


root@raspberrypi:/var/lock# /usr/sbin/apache2ctl -k start
Syntax error on line 178 of /etc/apache2/apache2.conf:
Error:\tApache has not been designed to serve pages while\n\trunning as root.  There are known race conditions that\n\twill allow any local user to read any file on the system.\n\tIf you still desire to serve pages as root then\n\tadd -DBIG_SECURITY_HOLE to the CFLAGS env variable\n\tand then rebuild the server.\n\tIt is strongly suggested that you instead modify the User\n\tdirective in your httpd.conf file to list a non-root\n\tuser.\n
Action '-k start' failed.

ls -lart /var/lock/apache2
total 0
drwxr-xr-x 2 root root 40 Aug 18 07:26 .
drwxrwxrwt 3 root root 60 Aug 18 07:26 ..


useradd -m www //它将创建用户的主目录即使不存在,不创建用户主目录

vi  /etc/apache2/envvars
export APACHE_RUN_USER=www
export APACHE_RUN_GROUP=www

成功了:
root@raspberrypi:/var/lock# /usr/sbin/apache2ctl -k start      
apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName

root@raspberrypi:/var/lock# ls -lart
drwxr-xr-x  2 www  root  40 Aug 18 07:33 apache2


调用apache2 -k start 后,提示如下内容:

apache2: bad user name ${APACHE_RUN_USER}  

apache 启动时,是由读取 /etc/apache2/apache2.conf 读取了运行 User

而运行的user环境变量定义在/etc/apache2/envvars

而不是使用默认的登录账户启动,因此apache提供了
apache2ctl 工具来使用,调用

apache2ctl -k start

即可~

来自:http://www.cnblogs.com/amaoxiaozhu/p/4311201.html

root@raspberrypi:/# find . -name apache2ctl
/usr/sbin/apache2ctl l -k restart

/usr/sbin/apache2ctl -k restart  
apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName

作者:jackxiang@向东博客 专注WEB应用 构架之美 --- 构架之美,在于尽态极妍 | 应用之美,在于药到病除
地址:https://jackxiang.com/post/8044/
版权所有。转载时必须以链接形式注明作者和原始出处及本声明!


最后编辑: jackxiang 编辑于2015-10-17 18:43
评论列表
发表评论

昵称

网址

电邮

打开HTML 打开UBB 打开表情 隐藏 记住我 [登入] [注册]