apache2: bad user name ${APACHE_RUN_USER} 解决方法

AndyYang| 阅读:2406 发表时间:2015-10-11 10:00:00 linuxapache
摘要:之前一直用的nginx,换了份新工作,发现公司用的apache,安装了memcache扩展需要重启,Debian重启apache提示如下内容:
之前一直用的nginx,换了份新工作,发现公司用的apache,安装了memcache扩展需要重启,Debian重启apache提示如下内容:
apache2: bad user name ${APACHE_RUN_USER}

apache启动时,读取/etc/apache2/apache2.conf文件,里边用到了环境变量 APACHE_RUN_USER,APACHE_RUN_USER定义在/etc/apache2/envvars
而不是使用默认的登录账户启动,因此apache提供了apache2ctl(Apache HTTP Server Control Interface)工具来使用。
apache2ctl -k start 
即可。

另外ubuntu的论坛里有另外一种解决方法以及发生该错误的原因说明:http://ubuntuforums.org/showthread.php?t=804436
下面是这位仁兄的解释:

I believe this is because etc/init.d is not in your command path. Unlike Windows, Linux does not look in the "current" directory for commands. So, if you are in /etc/init.d you can type "sudo ./apache2 restart" which will tell it to look in the current directory with the "./" The script in /etc/init.d/apache2 explicitly reads in the environment variables before calling /usr/sbin/apache2. /usr/sbin/ is in yoour command path, so that is the one that runs when you just type "apache2 ..."

他的意思是命令行的目录问题,在当前目录加./,不在当前目录写完整路径,另外加上sudo。例如:
cd /etc/init.d/
sudo apache2 -k restart  
会出现错误 ,这种情况下环境变量还没有读取

改成:
cd /etc/init.d/
sudo ./apache2 -k restart
或者
sudo /etc/init.d/apache2 -k restart
本文为AndyYang原创,转载请注明出处!
如果您觉得好,可以打赏作者:
如果您觉得累了,是否想看点美女养养眼:猛戳>>朋友帮
如果您觉得皮了,是否想来点神吐槽:猛戳>>iPhone查询中

已有1条评论

昵称:
邮箱:

  • 最新评论

阿帕奇2015-10-16 20:58:39
我也遇到了一模一样的问题,apache2ctl 走起。
iPhone查询中 - bbs.ipcxz.com 朋友帮 - www.pengyb.cn iPhone查询中 - bbs.ipcxz.com
反馈
微信订阅号