1

How do I fix this syntax error:

AH00526: Syntax error on line 4 of /etc/apache2/envvars:
Invalid command 'unset', perhaps misspelled or defined by 
a module not included in the server configuration  

Background:

I get an error at every startup. I think it is related to this issue, same errors:

Why is my Apache not working after upgrading to Ubuntu 14.04?

$ cat apport.log.1
ERROR: apport (pid 2081) Tue Dec 16 10:09:06 2014: called for pid 22820, signal 11, core limit 0
ERROR: apport (pid 2081) Tue Dec 16 10:09:06 2014: executable: /usr/sbin/apache2 (command line "/usr/sbin/apache2 -k start")
ERROR: apport (pid 2081) Tue Dec 16 10:09:06 2014: is_closing_session(): no DBUS_SESSION_BUS_ADDRESS in environment
ERROR: apport (pid 2081) Tue Dec 16 10:09:09 2014: wrote report /var/crash/_usr_sbin_apache2.0.crash

It seems odd that only one person mention envvars file. All the undefined vars are there, so the question I have is why envvars not loaded or is it being loaded too late?

I added

Include envvars

to /etc/apache2/apache2.conf@57 (before Mutex line) and reran

/usr/sbin/apache2 -k start

as seen in the log (I know this method of starting apache is deprecated; I don't know what script calls this (I presume /usr/sbin/apache2), but I need apport to stop choking on it because it is preventing other subsequent scripts from running) and I get a syntax error which I think is the source of the problem:

AH00526: Syntax error on line 4 of /etc/apache2/envvars:
Invalid command 'unset', perhaps misspelled or defined by 
a module not included in the server configuration  

So what is the fix for this syntax error?

Ubuntu 14.04 (3.13.0-43-generic) Server version: Apache/2.4.7 (Ubuntu) apport-cli -v 2.14.1


UPDATE: Here is my envvars file. I think it all stock.

# 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
# temporary state file location. This might be changed to /run in Wheezy+1
export APACHE_PID_FILE=/var/run/apache2/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 you would like to pass arguments to the web server, add them below
## to the APACHE_ARGUMENTS environment.
#export APACHE_ARGUMENTS=''

## Enable the debug mode for maintainer scripts.
## This will produce a verbose output on package installations of web server modules and web application
## installations which interact with Apache
#export APACHE2_MAINTSCRIPT_DEBUG=1
4
  • Sorry, I see. To start apache, you should use service command. If you want to run apache as binary, you should source envvars, not include. When you use service command apache is started by systemV script.
    – Lety
    Dec 22, 2014 at 17:35
  • I know 'apache2 -k start' is deprecated, but I'm not the one calling it that way. Based on the apport log it is /usr/sbin/apache2. Regardless, I need to fix the syntax error.
    – bfuzze
    Dec 22, 2014 at 18:18
  • I guess that the problem is that you should source /etc/apache2/envvars instead of include it in apache configuration file. If you want you could add /etc/apache2/envvars in your question, so we can help you to find out errors.
    – Lety
    Dec 23, 2014 at 0:15
  • Source would only work if "I" was calling the script, this is a startup process calling the script. I'll attach a copy of my envvars, but it is stock, no customizations.
    – bfuzze
    Dec 23, 2014 at 19:33

2 Answers 2

1

envvars is not an Apache configuration file to be included in apache2.conf. You're right that that file is stock, but your addition of

Include envvars

to apache2.conf is most certainly not stock. That file is sourced by the Apache2 init script (/etc/init.d/apache2) (several times, actually). The fix is to not include it.

7
  • I don't think you read the initial post, completely. I added the include because vars in the envvars file were not being initialized. Thanks.
    – bfuzze
    Dec 24, 2014 at 21:40
  • It occurs to me maybe you meant the include created an additional problem unrelated to initial. So maybe I'm asking the wrong question (?), Maybe the correct question is Why aren't the being initialized.
    – bfuzze
    Dec 24, 2014 at 21:53
  • @bfuzze that is the right question, and the answer is: use the init script! Or better, service apache2 restart.
    – muru
    Dec 25, 2014 at 0:29
  • Dude. Read the post. I'm not the one starting the apache, it's the system. I'm trying to resolve in issue with apport.
    – bfuzze
    Dec 26, 2014 at 1:33
  • @bfuzze I did and you're parking apport's log, containing warnings from apport instead of the crash report generated by apport. I did read your question. It's just filled with useless or meaningless information.
    – muru
    Dec 26, 2014 at 5:52
1

This answer to a similar question worked for me but also clobbered my user-level env vars such as $HOME.

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

I am looking for a clean solution to both problems now.

You must log in to answer this question.

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