3
owner@G700:/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

owner@G700:/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).

5
  • 1
    Perhaps your faulty config files for apache survived uninstall? Can you post the offending line in /etc/apache2/apache2.conf ? Try running vim +80 /etc/apache2/apache2.conf and it should open the offending config line ...
    – gmt42
    Mar 14, 2019 at 19:31
  • Is your config file line looking like DefaultRuntimeDir ${APACHE_RUN_DIR} ?
    – gmt42
    Mar 14, 2019 at 19:36
  • You should verify that your /etc/apache2/envvars file contains the line export APACHE_RUN_DIR=/var/run/apache2$SUFFIX .
    – gmt42
    Mar 14, 2019 at 19:42
  • Yes, line 80 shows: DefaultRuntimeDir ${APACHE_RUN_DIR}. As to your 2nd comment this is line 20: export APACHE_RUN_DIR=/var/run/apache2$SUFFIX
    – Sean D
    Mar 14, 2019 at 19:42
  • 1
    The problem is the rather awkward fact that calling apache2 binary directly doesn't set nor export environment variables from /etc/apache2/envvars. I don't now which versions it started to be obligatory to start /etc/init.d/apache2 start or service apache2 start, but now it is a must.
    – gmt42
    Mar 14, 2019 at 20:00

1 Answer 1

4

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:

root@efk:~# service apache2 stop
root@efk:~# /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
root@efk:~# service apache2 start
root@efk:~# apachectl --status
httpd (pid 28782) already running
root@efk:~# service apache2 stop
root@efk:~# /etc/init.d/apache2 start
[ ok ] Starting apache2 (via systemctl): apache2.service.
root@efk:~# apachectl --status
httpd (pid 28966) already running

So, it is evident that the apache2 must be called through init script and not by directly calling the binary. Now by calling init script I can confirm that it works either way, /etc/init.d/apache2 start or service apache2 start. Both start the daemon via the systemctl command.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .