参数文件中的Mutex目录无效:$ {APACHE_LOCK_DIR}

嗨,每个身体干净安装ubuntu 16.04和tasksel灯apache2后出现此错误:

[Mon Jul 18 22:42:00.114578 2016] [core:warn] [pid 4654] AH00111: Config variable ${APACHE_LOCK_DIR} is not defined [Mon Jul 18 22:42:00.114623 2016] [core:warn] [pid 4654] AH00111: Config variable ${APACHE_PID_FILE} is not defined [Mon Jul 18 22:42:00.114641 2016] [core:warn] [pid 4654] AH00111: Config variable ${APACHE_RUN_USER} is not defined [Mon Jul 18 22:42:00.114645 2016] [core:warn] [pid 4654] AH00111: Config variable ${APACHE_RUN_GROUP} is not defined [Mon Jul 18 22:42:00.114657 2016] [core:warn] [pid 4654] AH00111: Config variable ${APACHE_LOG_DIR} is not defined [Mon Jul 18 22:42:00.133748 2016] [core:warn] [pid 4654] 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} 

看起来你试图通过运行类似的东西来启动Apache

 apache2 

这不起作用。 使用

 sudo service apache2 start 

代替。

我碰到了这一次,这对我有用:

 source /etc/apache2/envvars apache2 -V sudo service apache2 restart 

从那以后我没有遇到过这个问题。

正确答案很简单但不明显。

Ubuntu / Debian中的apache2服务在启动时通过apache2ctl restartservice apache2 restart使用环境文件/etc/apache2/envvars

为了成功显示apache2 -V细节,只需获取apache2环境文件:

 # source /etc/apache2/envvars # apache2 -V 

apache2.conf不应该有任何语法错误,因为第74行中显示的环境变量在启动时由apache2自动获取。