Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.0k views
in Technique[技术] by (71.8m points)

magento - Apache: edit to .conf file produces "Invalid command 'Header'"

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

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>

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

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

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.

Site is running Apache 2.4

Have I done something wrong?

question from:https://stackoverflow.com/questions/34554240/apache-edit-to-conf-file-produces-invalid-command-header

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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

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

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

Issue following command :-

a2enmod headers

Restart web service

apache2ctl restart


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...