I installed apache2 on ubuntu 13.10. If I try to restart it using

sudo /etc/init.d/apache2 restart

I get this message:

AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message

So I read that I should edit my httpd.conf file. But, since I can't find it in /etc/apache2/ folder, I tried to locate it using this command:

/usr/sbin/apache2 -V

But the output I get is this:

[Fri Nov 29 17:35:43.942472 2013] [core:warn] [pid 14655] AH00111: Config variable ${APACHE_LOCK_DIR} is not defined
[Fri Nov 29 17:35:43.942560 2013] [core:warn] [pid 14655] AH00111: Config variable ${APACHE_PID_FILE} is not defined
[Fri Nov 29 17:35:43.942602 2013] [core:warn] [pid 14655] AH00111: Config variable ${APACHE_RUN_USER} is not defined
[Fri Nov 29 17:35:43.942613 2013] [core:warn] [pid 14655] AH00111: Config variable ${APACHE_RUN_GROUP} is not defined
[Fri Nov 29 17:35:43.942627 2013] [core:warn] [pid 14655] AH00111: Config variable ${APACHE_LOG_DIR} is not defined
[Fri Nov 29 17:35:43.947913 2013] [core:warn] [pid 14655] AH00111: Config variable ${APACHE_LOG_DIR} is not defined
[Fri Nov 29 17:35:43.948051 2013] [core:warn] [pid 14655] AH00111: Config variable ${APACHE_LOG_DIR} is not defined
[Fri Nov 29 17:35:43.948075 2013] [core:warn] [pid 14655] 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}

Line 74 of /etc/apache2/apache2.conf is this:

Mutex file:${APACHE_LOCK_DIR} default

I gave a look at my /etc/apache2/envvar file, but I don't know what to do with it.

What should I do?

  • What is in your envvars file? – etagenklo Nov 29 '13 at 17:48
up vote 49 down vote accepted
[Fri Nov 29 17:35:43.942472 2013] [core:warn] [pid 14655] AH00111: Config variable ${APACHE_LOCK_DIR} 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 ServerName variable in /etc/apache2/apache2.conf to localhost or your prefered FQDN.

  • 1
    You're right about the init script. Then I added ServerName localhost to apache2.conf (because httpd.conf is not always used on Ubuntu) and now everything works as it should. Could you please add details to your answers, so that I can flag it as accepted? – Kurt Bourbaki Nov 30 '13 at 17:57
  • 1
    starting with apache2ctl didn't work for me, I had to use the service: sudo service apache2 restart – Édouard Lopez Aug 6 '14 at 13:29
  • But why did they break the apache2 command in the first place? – reinierpost Jun 16 '16 at 19:24
  • 2
    This solutions only solves AH00558: apache2: Could not reliably determine the server's fully qualified domain name but it does not solve Config variable ${APACHE_LOCK_DIR} is not defined. – Vladimir Vukanac Jul 13 '16 at 20:36
  • for me also i see the same issue. – nepsdotin Oct 14 '16 at 13:09

Source your envvars by running it like this:

source /etc/apache2/envvars

and then

/usr/sbin/apache2 -V

You should get:

el@apollo:/home/el$ apache2 -V
Server version: Apache/2.4.7 (Ubuntu)
Server built:   Apr  3 2014 12:20:28
Server's Module Magic Number: 20120211:27
Server loaded:  APR 1.5.1-dev, APR-UTIL 1.5.3
Compiled using: APR 1.5.1-dev, APR-UTIL 1.5.3
Architecture:   64-bit
Server MPM:     prefork
  threaded:     no
    forked:     yes (variable process count)
Server compiled with....
 -D APR_HAS_SENDFILE
 -D APR_HAS_MMAP
 -D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
 -D APR_USE_SYSVSEM_SERIALIZE
 -D APR_USE_PTHREAD_SERIALIZE
 -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
 -D APR_HAS_OTHER_CHILD
 -D AP_HAVE_RELIABLE_PIPED_LOGS
 -D DYNAMIC_MODULE_LIMIT=256
 -D HTTPD_ROOT="/etc/apache2"
 -D SUEXEC_BIN="/usr/lib/apache2/suexec"
 -D DEFAULT_PIDLOG="/var/run/apache2.pid"
 -D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
 -D DEFAULT_ERRORLOG="logs/error_log"
 -D AP_TYPES_CONFIG_FILE="mime.types"
 -D SERVER_CONFIG_FILE="apache2.conf"
  • /etc/apache2/envvars doesn't exist – Mark Richman Jul 10 '14 at 18:20
  • 6
    The file does exist on my ubuntu system, but the shell doesn't recognize it as a shell script, so I need this: source /etc/apache2/envvars ; apache2 -V – Ben Crowell Jul 10 '14 at 18:59
  • 1
    This should be the accepted answer!! Thanks! – VaTo Aug 18 '16 at 1:46
  • 6
    Could just use apachectl -V instead of loading in the environment variables manually. – Sam Sehnert Jan 24 '17 at 22:58
  • If still not working, try source /etc/apache2/envvars && sudo -E apache2 -V or login as root and do per answer above. Sourcing the apache2 env to a regular user who then needs to use sudo will not work w/o "-E". Regular user perms cannot read certificate private folder among other problems. You will get an error. You need to sudo -E or run under root account completely. – bshea Aug 11 '17 at 14:36

Check your /etc/apache2/envvars for the APACHE_LOCK_DIR. In my Ubuntu 12.04, this is /var/lock/apache2$SUFFIX, being SUFFIX normally empty.

Check if the directory exists and is writable.

May it be that the envvars file is not sourced correctly? If you have a look at /etc/init.d/apache2 you can see that it sourced.

My (default) /etc/apache2/envvars:

# envvars - default environment variables for apache2ctl

# this won't be correct after changing uid
unset HOME

# for supporting multiple apache2 instances
if [ "${APACHE_CONFDIR##/etc/apache2-}" != "${APACHE_CONFDIR}" ] ; then
    SUFFIX="-${APACHE_CONFDIR##/etc/apache2-}"
else
    SUFFIX=
fi

# Since there is no sane way to get the parsed apache2 config in scripts, some
# settings are defined via environment variables and then used in apache2ctl,
# /etc/init.d/apache2, /etc/logrotate.d/apache2, etc.
export APACHE_RUN_USER=www-data
export APACHE_RUN_GROUP=www-data
export APACHE_PID_FILE=/var/run/apache2$SUFFIX.pid
export APACHE_RUN_DIR=/var/run/apache2$SUFFIX
export APACHE_LOCK_DIR=/var/lock/apache2$SUFFIX
# Only /var/log/apache2 is handled by /etc/logrotate.d/apache2.
export APACHE_LOG_DIR=/var/log/apache2$SUFFIX

## The locale used by some modules like mod_dav
export LANG=C
## Uncomment the following line to use the system default locale instead:
#. /etc/default/locale

export LANG

## The command to get the status for 'apache2ctl status'.
## Some packages providing 'www-browser' need '--dump' instead of '-dump'.
#export APACHE_LYNX='www-browser -dump'

## If you need a higher file descriptor limit, uncomment and adjust the
## following line (default is 8192):
#APACHE_ULIMIT_MAX_FILES='ulimit -n 65536'

If nothing works I would try to reinstall the package(s).

As other said, you have to load (source) your environment before running it directly Another option is to use: apache2ctl e.g.

sudo apache2ctl -S

to dump my hosts

TL;DR; You should start apache2 using what you already have:

sudo /etc/init.d/apache2 {start|stop|restart}

Detailed:

AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message

This message means you need to define your server name / domain name. It's not essential to do it for a localhost/testing of production, you don't need to worry about it.

When you try to run it the other way, using only apache2, you'll get those error messages because of what was said before: the environment variables are defined when you start using the default script in init.d.

Maybe this will resolve your problem

sudo bash -c '. /etc/apache2/envvars ; apache2'
  • 1
    read first, exactly this line was provided already, and it was also explained, why it is not a correct answer. – asdmin Jun 6 '16 at 11:08

You need to update the DocumentRoot from /var/www/html to /var/www

Edit the file /etc/apache2/sites-available/000-default.conf as follows

DocumentRoot /var/www

This works for me

sudo -u root bash -c "source /etc/apache2/envvars; apache2 -V"
  • In the question, there was a problem (an error message about ServerName) and a failing debug method (which is caused by not sourcing the environment variables) .Your answer addresses the debug method, and not the question. – asdmin Jun 6 '16 at 9:28

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.