由于做计网课设时需要用到apache2,所以开始在ubuntu上安装apache2;
安装挺简单的,只需要在ubuntu终端里输入:
sudo apt-get install apache2
然后回车就可以了;
然而,在安装成功准备运行的时候,却出现了问题如下所示:
[Fri Oct 14 20:27:03.977120 2016] [core:warn] [pid 4445] AH00111: Config variable ${APACHE_LOCK_DIR} is not defined
[Fri Oct 14 20:27:03.977236 2016] [core:warn] [pid 4445] AH00111: Config variable ${APACHE_PID_FILE} is not defined
[Fri Oct 14 20:27:03.977267 2016] [core:warn] [pid 4445] AH00111: Config variable ${APACHE_RUN_USER} is not defined
[Fri Oct 14 20:27:03.977273 2016] [core:warn] [pid 4445] AH00111: Config variable ${APACHE_RUN_GROUP} is not defined
[Fri Oct 14 20:27:03.977283 2016] [core:warn] [pid 4445] AH00111: Config variable ${APACHE_LOG_DIR} is not defined
[Fri Oct 14 20:27:03.979139 2016] [core:warn] [pid 4445:tid 140654039287680] AH00111: Config variable ${APACHE_LOG_DIR} is not defined
[Fri Oct 14 20:27:03.981408 2016] [core:warn] [pid 4445:tid 140654039287680] AH00111: Config variable ${APACHE_LOG_DIR} is not defined
[Fri Oct 14 20:27:03.981422 2016] [core:warn] [pid 4445:tid 140654039287680] AH00111: Config variable ${APACHE_LOG_DIR} is not defined
AH00526: Syntax error on line 74 of /etc/apache2/apache2.conf:
Invalid Mutex directory in argument file:${APACHE_LOCK_DIR}
找了很久才在http://serverfault.com/questions/558283/apache2-config-variable-is-not-defined里找到了和我情况类似的朋友的帖子,在回帖里发现了答案,回帖如下:
this message is displayed because you directly executed the apache2 binary. In Ubuntu/Debian the apache config
relies on the envvar file which is only activated if you start apache with the init script or apachectl.
your original problem is that you have no a proper hostname (fqdn) for your machine. if you can't change it, change the Ser verName
variable in /etc/apache2/apache2.conf
to localhost
or your prefered FQDN.
大概意思就是apache的配置需要依赖envvar这个文件,但是这个文件只有在用init script或apachectl运行apache才有有效,所以我就试
了一下方法:
在ubuntu终端里直接输入
sudo apachectl start
结果apache2就成功跑起来了,至于为什么会这样,我就不清楚了,希望哪位大神可以解析一下;