Apache:对.conf文件的编辑会产生“无效命令'Header'"; [英] Apache: edit to .conf file produces "Invalid command 'Header'"

查看:273
本文介绍了Apache:对.conf文件的编辑会产生“无效命令'Header'";的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Magento CE中,我想为Extendware页面缓存安装一个名为Lightening Cache的加载项.

In Magento CE, I'd like to install an add-on to Extendware Page Cache called Lightening Cache.

它需要通过添加以下内容来在网站的虚拟主机定义中编辑Apache配置:

It requires editing the Apache configuration inside the virtual host definition for the site, by adding:

RewriteEngine On
RewriteMap ewpchash prg:/home/.../shell/extendware/ewpagecache/apache/md5.php

RewriteCond %{REQUEST_METHOD} !POST
RewriteCond %{REQUEST_URI} !\.(js|css|png|jpg|jpeg|ico|gif)$ [NC]
RewriteCond %{DOCUMENT_ROOT}%{SCRIPT_FILENAME} !-f
RewriteCond ${ewpchash:%{HTTPS};~;%{HTTP_HOST};~;%{REQUEST_URI};~;%{QUERY_STRING};~;%{HTTP:Cookie};~;%{SCRIPT_FILENAME};~;%{REMOTE_ADDR};~;%{HTTP_USER_AGENT}} -f
RewriteRule ^(.*)$ ${ewpchash:%{HTTPS};~;%{HTTP_HOST};~;%{REQUEST_URI};~;%{QUERY_STRING};~;%{HTTP:Cookie};~;%{SCRIPT_FILENAME};~;%{REMOTE_ADDR};~;%{HTTP_USER_AGENT}} [NC,L]
<FilesMatch "\.(html)$">
     Header unset Cache-Control
     Header unset Expires
     Header append Expires "Thu, 19 Nov 1981 08:52:00 GMT"
     Header append Cache-Control "must-revalidate"
</FilesMatch>

我已将其添加到/etc/apache2/sites-enabled/site.conf

I have added this to the bottom of /etc/apache2/sites-enabled/site.conf

当我运行命令"apachectl graceful"时,收到错误消息:

When I run the command "apachectl graceful', I receive the error:

AH00526:第53行的语法错误 /etc/apache2/sites-enabled/site.conf:无效的命令"Header", 可能是由服务器中未包含的模块拼写错误或定义的 配置操作正常"失败. Apache错误日志可能有 更多信息.

AH00526: Syntax error on line 53 of /etc/apache2/sites-enabled/site.conf: Invalid command 'Header', perhaps misspelled or defined by a module not included in the server configuration Action 'graceful' failed. The Apache error log may have more information.

站点正在运行Apache 2.4

Site is running Apache 2.4

我做错了什么吗?

推荐答案

为了在Apache中使用Header指令,您必须加载mod_header模块. 您可以通过以下方法测试模块是否已加载:-

In order to use Header directive in apache you have to load mod_header module. You can test if module is loaded or not by :-

apache2ctl -M | grep headers_module

find / -name mod_headers.so

如果已加载,您将看到类似:-

If it is loaded you will see something like :-

headers_module (shared)

/usr/lib/apache2/modules/mod_headers.so

如果您没有找到find命令的输出,则直接在apache conf文件中加载了该模块.只需在行以下附加:-

If you see no output of find command than load that module directly in your apache conf file. Just append below line :-

LoadModule headers_module modules/mod_headers.so

注意:- mod_header可用作Apache中的基本模块.因此,您无需显式安装它.

Note :- mod_header is available as base module in apache. So you don't need to install it explicitly.

发出以下命令:-

a2enmod headers

重新启动Web服务

apache2ctl restart

这篇关于Apache:对.conf文件的编辑会产生“无效命令'Header'";的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆