Trouble getting DEFLATE working on Apache 2.2

apache-2.2compression

I discovered that my server isn't serving up compressed pages.

Using this answer, I added the following to my httpd conf file:

# Declare a "gzip" filter, it should run after all internal filters like PHP or SSI
FilterDeclare  gzip CONTENT_SET

# "gzip" filter can change "Content-Length", can not be used with range requests
FilterProtocol gzip change=yes;byteranges=no

# Enable "gzip" filter if "Content-Type" contains "text/html", "text/css" etc.
FilterProvider gzip DEFLATE resp=Content-Type $text/html
FilterProvider gzip DEFLATE resp=Content-Type $text/css
FilterProvider gzip DEFLATE resp=Content-Type $text/javascript
FilterProvider gzip DEFLATE resp=Content-Type $application/javascript
FilterProvider gzip DEFLATE resp=Content-Type $application/x-javascript

# Add "gzip" filter to the chain of filters
FilterChain    gzip

Next, I issued

apachectl configtest

which yielded this error:

Invalid command 'FilterDeclare', perhaps misspelled or defined by a
module not included in the server configuration

Here's output from httpd -l

Compiled in modules:
  core.c
  prefork.c
  http_core.c
  mod_so.c

What module(s) do I need to install to get page compression working? I am running CentOS 6.6.

Best Answer

In Centos mod_filter are not loaded by default, you need add or uncomment in your httpd.conf the following line:

LoadModule filter_module modules/mod_filter.so

Don't forget reload your changes

service httpd graceful