The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

mod_gzip to work with all virtual hosts?

Discussion in 'General Discussion' started by webignition, Jan 31, 2005.

  1. webignition

    webignition Well-Known Member

    Joined:
    Jan 22, 2005
    Messages:
    1,880
    Likes Received:
    0
    Trophy Points:
    36
    I've just added Gzip for the first time (still new to this, hadn't really heard of it before).

    I added it using WHM > Software > Update Apache and ticked the relevant option.

    However I'm not getting gzip content encoding for hosted domains.

    I'm checking with http://leknor.com/code/gziped.php and when checking the my server's hostname, it says that the content is gzip enabled however when checking individual domains, they are showing as not being gzip enabled.

    I took a look at my httpd.conf and it seems to be OK. I have:

    Code:
    LoadModule gzip_module modules/mod_gzip.so
    and

    Code:
    AddModule mod_gzip.c
    present and apparentlty in the right places and the following at the very end of the file:

    Code:
    <IfModule mod_gzip.c>
    mod_gzip_on yes
    
    mod_gzip_send_vary yes
    
    mod_gzip_dechunk yes
    mod_gzip_keep_workfiles No
    mod_gzip_temp_dir /tmp
    mod_gzip_minimum_file_size  1002
    mod_gzip_maximum_file_size  0
    mod_gzip_maximum_inmem_size 1000000
    
    mod_gzip_item_include file "\.htm$"
    mod_gzip_item_include file "\.html$"
    mod_gzip_item_include mime "text/.*"
    mod_gzip_item_include file "\.php$"
    mod_gzip_item_include mime "jserv-servlet"
    mod_gzip_item_include handler "jserv-servlet"
    mod_gzip_item_include mime "application/x-httpd-php.*"
    mod_gzip_item_include mime "httpd/unix-directory"
    
    mod_gzip_item_exclude file "\.css$"
    mod_gzip_item_exclude file "\.js$"
    mod_gzip_item_exclude file "\.wml$"
    </IfModule>
    This seems to show that gzip is installed and enabled.

    However the problem, as you've seen, is that it only works for my server's hostname and not for the domains hosted on my server i.e. all the <VirtualHost> entries in httpd.conf.

    Out of curiosity, I tried adding the last mentioned chunk of httpd.conf into a <VirtualHost> section just to see if it would work with a specific domain, but to no avail.

    I've tried Googling and all the info I can find suggests that httpd.conf is set correctly, yet I'm not getting gzipped content from anything other than my server's hostname.

    Any ideas?
     
  2. rpmws

    rpmws Well-Known Member

    Joined:
    Aug 14, 2001
    Messages:
    1,824
    Likes Received:
    5
    Trophy Points:
    38
    Location:
    back woods of NC, USA
    try calling a domain.com/pagename.html in that tester site and see what you get.
     
  3. webignition

    webignition Well-Known Member

    Joined:
    Jan 22, 2005
    Messages:
    1,880
    Likes Received:
    0
    Trophy Points:
    36
    Some success . . .

    I don't have much to test with as the server is new and only two domains have been transferred to it so far.

    Of the two domain names I can test with, when I try domain.com/pagetester.html (or more specifically something specific), I get gzipped content for one and not the other.

    For both I tried with a both html and php files and still it worked with one domain and not the other.

    If it makes a difference, the one it works with is on the first account that was added in WHM.

    Does that indicate anything useful?

    [Edit]

    I forgot to mention, if I visit check http://hostname.com/~specificuser/validfile.html I don't get gzipped content, whereas if I go to http://specificuser.com/validfile.html I do get gzipped content ?? Admittedly this is only valid for the one domain for whichi I do get gzipped content.
     
    #3 webignition, Jan 31, 2005
    Last edited: Jan 31, 2005
  4. rpmws

    rpmws Well-Known Member

    Joined:
    Aug 14, 2001
    Messages:
    1,824
    Likes Received:
    5
    Trophy Points:
    38
    Location:
    back woods of NC, USA
    weird ..i am stumped.
     
  5. anup123

    anup123 Well-Known Member

    Joined:
    Mar 29, 2004
    Messages:
    897
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    This Planet
    Just a wild shot in the dark.
    These are the defaults which come with mod_gzip

    mod_gzip_minimum_file_size 500
    mod_gzip_maximum_file_size 500000
    mod_gzip_maximum_inmem_size 60000
    mod_gzip_min_http 1000
    mod_gzip_handle_methods GET POST
    mod_gzip_item_exclude reqheader "User-agent: Mozilla/4.0[678]"

    Few of the above are missing, values changed particularly these two are missing:

    mod_gzip_min_http 1000
    mod_gzip_handle_methods GET POST

    Also try removing the double quotes for example something like this

    mod_gzip_item_include file \.html$
    mod_gzip_item_include file \.jsp$
    mod_gzip_item_include file \.php$
    mod_gzip_item_include file \.php3$
    mod_gzip_item_include file \.pl$
    mod_gzip_item_include file \.cgi$
    mod_gzip_item_include mime ^text/.*
    mod_gzip_item_include mime ^application/x-httpd-php
    mod_gzip_item_include mime ^httpd/unix-directory$
    mod_gzip_item_include handler ^perl-script$
    mod_gzip_item_include handler ^cgi-script$
    mod_gzip_item_include handler ^server-status$
    mod_gzip_item_include handler ^server-info$
    mod_gzip_item_exclude file \.css$
    mod_gzip_item_exclude file \.js$



    Try and see if that can make it work

    I always used mod_gzip compiled in as DSO and never from cPanel easyapache.


    Anup
     
    #5 anup123, Feb 1, 2005
    Last edited: Feb 1, 2005
  6. webignition

    webignition Well-Known Member

    Joined:
    Jan 22, 2005
    Messages:
    1,880
    Likes Received:
    0
    Trophy Points:
    36
    Thanks anup123 - I'll give this a go later when I have the time and see what happens . . . fingers crossed!
     
  7. webignition

    webignition Well-Known Member

    Joined:
    Jan 22, 2005
    Messages:
    1,880
    Likes Received:
    0
    Trophy Points:
    36
    Hmmm

    Well, I made those changes you suggested anup123 but unfortunately it made no difference - its still the same as before.

    I get gzipped content for one domain and no others.

    What I'd really appreciate is seeing an httpd.conf from someone where gzipping works for all virtual hosts. I could them compare this to mine and spot what might be wrong.

    Is there any chance someone could supply me with one? I wouldn't expect someone to post it here, but if someone could possibly mail it to me (PM me to begin with) that would great.

    I'd also happily give my full httpd.conf to someone if they would be kind enough to peruse through it with me and compare it to one that works correctly.
     
  8. anup123

    anup123 Well-Known Member

    Joined:
    Mar 29, 2004
    Messages:
    897
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    This Planet
    I had difficulties with getting mod_gzip to work when compiled with using easyapache.
    There is really nothing that needs to be done in <VirtualHost> container as such.

    Though a painful approach, but i would still suggest:

    recompile your apache not using mod_gzip in WHM

    download mod_gzip-1.3.26.1a.tgz (or whatever the latest version) from sourceforge.net

    tar -zxvf mod_gzip-1.3.26.1a.tgz
    cd mod_gzip-1.3.26.1a

    make APXS=/usr/local/apache/bin/apxs
    make install APXS=/usr/local/apache/bin/apxs

    Then edit your httpd.conf file and add the following (after the end of AddModule stuff):

    <IfModule mod_gzip.c>
    mod_gzip_on Yes
    mod_gzip_can_negotiate Yes
    mod_gzip_static_suffix .gz
    AddEncoding gzip .gz
    mod_gzip_update_static No
    mod_gzip_command_version '/mod_gzip_status'
    mod_gzip_temp_dir /tmp
    mod_gzip_keep_workfiles No
    mod_gzip_minimum_file_size 500
    mod_gzip_maximum_file_size 500000
    mod_gzip_maximum_inmem_size 60000
    mod_gzip_min_http 1000
    mod_gzip_handle_methods GET POST
    mod_gzip_item_exclude reqheader "User-agent: Mozilla/4.0[678]"
    mod_gzip_item_include file \.html$
    mod_gzip_item_include file \.shtml$
    mod_gzip_item_include file \.htm$
    mod_gzip_item_include file \.shtm$
    mod_gzip_item_include file \.php$
    mod_gzip_item_include file \.phtml$
    mod_gzip_item_exclude file \.js$
    mod_gzip_item_exclude file \.css$
    mod_gzip_item_exclude file \.wml$
    mod_gzip_item_include file \.pl$
    mod_gzip_item_include file \.cgi$
    mod_gzip_item_include handler ^cgi-script$
    mod_gzip_item_include mime ^text/html$
    mod_gzip_item_include mime ^text/plain$
    mod_gzip_item_include mime ^httpd/unix-directory$
    mod_gzip_item_include mime ^application/x-httpd-php
    mod_gzip_item_include handler ^perl-script$
    mod_gzip_item_exclude mime ^image/
    mod_gzip_dechunk Yes
    mod_gzip_add_header_count Yes
    mod_gzip_send_vary Yes
    </IfModule>


    Save the file
    Restart apache

    That's about it. There is nothing too typical about installtion and getting it to work, except for in cases where one is using mod_proxy also for proxying a back-end httpd in which case mod_gzip would fail because of a bug. Other than that it works fine.

    Anup
     
  9. webignition

    webignition Well-Known Member

    Joined:
    Jan 22, 2005
    Messages:
    1,880
    Likes Received:
    0
    Trophy Points:
    36
    Woo Hoo!

    Thanks again anup123.

    Well, it seems to be working now although I can't be sure if it wasn't working before and I just didn't fully understand the config.

    For more than one domain, some URLs return gzipped content (both php and html) and some don't and I seem to get the impression that if the output served by Apache is lower than a certain amount of bytes it doesn't bother gzipping.

    Either way, thanks very much for all your help. I can certainly see that there is gzipped content from more than one domain and so I'm happy with that :)
     
  10. anup123

    anup123 Well-Known Member

    Joined:
    Mar 29, 2004
    Messages:
    897
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    This Planet
    How are you seeing whether compression is working or not?
    You could try the Custom Log directive to be 100% sure and you could see the precompression and post compression sizes being reported in the logs along with % compression.

    Glad that it's working.

    Anup
     
  11. rpmws

    rpmws Well-Known Member

    Joined:
    Aug 14, 2001
    Messages:
    1,824
    Likes Received:
    5
    Trophy Points:
    38
    Location:
    back woods of NC, USA
    If your files call a css file then sometimes the inclusion of that wrecks it if you don't have css included in your config.
     
Loading...

Share This Page