0

I know that my site is not sending data gzipped. I tested that using site like http://www.gidnetwork.com/tools/gzip-test.php

Now I want to know if apache is compiled with gzip module or not. Before I put in the code that will serve the compressed content I want to test if gzip is enabled on my apache server or do I need to build it. How do I test that. How do I put a debug statement that will show up in apache log. I believe I can do something like this but not sure.

 <IfModule mod_gzip.c>  
   log('apache is configured with gzip. no need to install it')  
</IfModule>

What code will go in place of log so that I could see the message in apache log. Also how can I write else statement so that I get a message either way.

Here is my apache.conf

# Include module configuration:
Include /etc/apache2/mods-enabled/*.load
Include /etc/apache2/mods-enabled/*.conf

# Include all the user configurations:
Include /etc/apache2/httpd.conf

# Include ports listing
Include /etc/apache2/ports.conf

This is the list of items in mods-enabled directory

root@me:/etc/apache2/mods-enabled# ls
alias.conf       authn_file.load       authz_host.load  autoindex.load  dir.load   mime.load         setenvif.conf  status.load
alias.load       authz_default.load    authz_user.load  cgi.load        env.load   negotiation.conf  setenvif.load
auth_basic.load  authz_groupfile.load  autoindex.conf   dir.conf        mime.conf  negotiation.load  status.conf

3 Answers 3

2

try running from command line:

apache2 -l

this should give you list of modules built into apache. more probably you'll have gzip as additional loadable module called mod_deflate.so - check if any of your .load loads this one.

if you use debian'ish distro [ it seems so ] just symlink deflate.load and deflate.conf from mods-available to mods-enabled:

cd /etc/apache2/mods-enabled/
ln -s ../mods-available/deflate.load
ln -s ../mods-available/deflate.conf

and reload apache2

/etc/init.d/apache2 reload
0
0

Check the output of :

httpd -M 2<&1 | grep gzip

?

2
  • root@eiiv2:/etc/apache2/mods-available# httpd -bash: httpd: command not found
    – Roger
    Aug 26, 2009 at 21:45
  • This would be for RedHat or CentOS
    – sMyles
    May 15, 2015 at 4:40
0

I'm assumming Apache 2.....Just because the deflate module is present, does not necessarily imply that output compression happens. It is necessary to add the directive where you want output to be gzipped:

SetOutputFilter DEFLATE

There are other options so that only certain types of files are gzipped as well.

I'd suggest that you might look at the deflate module description in http://httpd.apache.org.

4
  • I just setup the symlink and now gzip test by gidnetwork.com/tools/gzip-test.php and whatsmyip.org/http_compression indicates that content is indeed zipped. I did not set SetOutputFilter DEFLATE Could you please explain why this directive is needed and why even without that directive I am getting my content zipped. The site is www.EventsInIndia.com .
    – Roger
    Aug 27, 2009 at 3:22
  • When I implemented this feature, I had to include this directive otherwise the output did not arrive in zipped form for the browser. The description of the module is at: httpd.apache.org/docs/2.2/mod/mod_deflate.html Hope this helps
    – mdpc
    Aug 27, 2009 at 4:08
  • Thanks mdpc. That helps. One last question. I have four vhosts in my apache config. vhost config is like this <VirtualHost xx.xx.xx.xx:80> ServerName xxxxxx ServerAlias xxxxxxxxxx DocumentRoot /home/xxxx/current/public <Directory "/home/xxx/current/public"> Options FollowSymLinks AllowOverride None Order allow,deny Allow from all </Directory> </VirtualHost> I was wondering if I need to put <Location /> ... <Location> inside the vhost config which means I will repeast same info 4 times or can I put the same code at a global level just before vhost declaration
    – Roger
    Aug 27, 2009 at 4:30
  • Also there is an end of element tag at the very first line. <Location /> And then there is end of tag at the bottom </Location>. Is <Location /> a typo. Should it be <Location> ?
    – Roger
    Aug 27, 2009 at 4:32

You must log in to answer this question.

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