Apache 环境变量语法错误

Apache 环境变量语法错误

我该如何修复这个语法错误:

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  

背景:

每次启动时都会出错。我认为这与此问题有关,同样的错误:

为什么升级到 Ubuntu 14.04 后我的 Apache 无法工作?

$ 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

只有一个人提到了 envvars 文件,这似乎很奇怪。所有未定义的变量都在那里,所以我的问题是为什么 envvars 没有加载,或者加载得太晚了?

我补充道

Include envvars

到 /etc/apache2/apache2.conf@57 (在 Mutex 行之前)并重新运行

/usr/sbin/apache2 -k start

如日志中所示(我知道这种启动 apache 的方法已被弃用;我不知道哪个脚本调用了它(我推测是的/usr/sbin/apache2),但我需要 apport 来停止阻塞它,因为它阻止了其他后续脚本运行)并且我收到一个语法错误,我认为这是问题的根源:

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  

那么如何修复这个语法错误呢?

Ubuntu 14.04(3.13.0-43-generic)服务器版本:Apache/2.4.7(Ubuntu)apport-cli -v 2.14.1


更新:这是我的 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
# 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

答案1

envvars不是要包含在 中的 Apache 配置文件apache2.conf。你说得对,该文件是库存文件,但你添加的

Include envvars

肯定不是现成的apache2.conf。该文件由 Apache2 init 脚本 ( ) 提供/etc/init.d/apache2(实际上有好几次)。修复方法是不是包括它。

答案2

回答类似的问题对我有用,但也破坏了我的用户级环境变量,例如$HOME。

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

我现在正在寻找一个可以彻底解决这两个问题的解决方案。

相关内容