日期:2014-05-16  浏览次数:20815 次

停止 apache2

今天发现服务器上Tomcat 8080端口起不来,老提示端口已经被占用。

使用命令:

ps -aux | grep tomcat

发现并没有8080端口的Tomcat进程。

使用命令:netstat –apn

?

?

?

?

Ubuntu - Apache2 - apache2: bad user name ${APACHE_RUN_USER}

在Ubuntu下sudo apt-get install apache2安装完Apache2以后,启动apache2的默认用户名是www-data, 属于www-data用户组

在shell中按如下输入

#apache2

会出现错误提示:

apache2: bad user name ${APACHE_RUN_USER}

?

解决方法:之前javaeye上有人的解决方法是直接改用户变量,apache2 启动会读取 /etc/apache2/apache2.conf 文件,里边用到了环境变量 APACHE_RUN_USER ;后者在 /etc/apache2/envars 里有定义 ,值为 www-data ,http://congfeng02.iteye.com/blog/435313 的方法是直接在 apache2.conf 的 user 那里用静态的值 www-data 。我在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 ..."

?

他的意思是命令行的目录问题,具体是

?

? -$ cd /etc/init.d/

? -$ sudo apache2 -k restart? 会出现错误 ,这种情况下环境变量还没有读取

?

?-$ sudo /etc/init.d/apache2 -k restart

或者

-$ cd /etc/init.d/

-$ sudo ./apache2 -k restart 这两种命令都不会出现该错误