apache2 --version shows error, -v does not

by Sean Dezoysa   Last Updated March 14, 2019 20:02 PM

[email protected]:/var/www/wptest1$ apache2 --version
[Fri Mar 15 01:29:11.505305 2019] [core:warn] [pid 4929]
 AH00111: Config variable ${APACHE_RUN_DIR} is not defined
apache2: Syntax error on line 80 of /etc/apache2/apache2.conf: 
DefaultRuntimeDir must be a valid 
directory, absolute or relative to ServerRoot

[email protected]:/var/www/wptest1$ apache2 -v
Server version: Apache/2.4.29 (Ubuntu)
Server built:   2018-10-10T18:59:25

I'm on Lubuntu 18.04. I have removed/purged and installed, and restarted apache2 about 10 times trying to fix this (as it may relate to php not working / php files showing raw code in browser).



Answers 1


The main error is:

AH00111: Config variable ${APACHE_RUN_DIR} is not defined

You should try to run apache via the /etc/init.d/apache2 start/stop script, not the binary directly. The script should export all environment variables needed, from /etc/apache2/envvars.

Try:

# service apache2 restart

See the explanation here:

https://serverfault.com/questions/558283/apache2-config-variable-is-not-defined

I can reproduce your error:

[email protected]:~# service apache2 stop
[email protected]:~# /usr/sbin/apache2 --version
[Thu Mar 14 20:54:17.111349 2019] [core:warn] [pid 28733] AH00111: Config variable ${APACHE_RUN_DIR} is not defined
apache2: Syntax error on line 80 of /etc/apache2/apache2.conf: DefaultRuntimeDir must be a valid directory, absolute or relative to ServerRoot
[email protected]:~# service apache2 start
[email protected]:~# apachectl --status
httpd (pid 28782) already running
gmt42
gmt42
March 14, 2019 19:52 PM

Related Questions


Updated October 04, 2018 12:02 PM

Updated January 11, 2019 12:02 PM

Updated January 30, 2019 23:02 PM

Updated November 02, 2015 11:01 AM

Updated June 24, 2017 16:02 PM