PDA

View Full Version : HOWTO: Install mod_gzip


loopforever
06-23-2003, 08:32 PM
**UPDATE March 30, 2005 **
I noticed a number of posts in this thread regarding imaging caching issues. I have updated the mod_gzip configuration below to resolve this issue. If you find you are experiancing image caching issues, I suggest you use this new configuration.


cd /root
wget http://aleron.dl.sourceforge.net/sourceforge/mod-gzip/mod_gzip-1.3.26.1a.tgz

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


You must now open Makefile in your favorite editor and change the first line to:

APXS?=/usr/sbin/apxs

Save it, and continue:


make build
make install


Next, open /etc/httpd/conf/httpd.conf in your favorite editor. The installer has already modified the httpd.conf file for you, but you'll need to make some minor changes. When you reach the LoadModule section of httpd.conf, find the mod_gzip line (commented out) and delete it. After all the LoadModules, paste:

LoadModule gzip_module /usr/lib/apache/mod_gzip.so
#LoadModule frontpage_module /usr/lib/apache/mod_frontpage.so
LoadModule perl_module /usr/lib/apache/libperl.so

<IfModule mod_gzip.c>
mod_gzip_on Yes
mod_gzip_minimum_file_size 300
mod_gzip_maximum_file_size 0
mod_gzip_maximum_inmem_size 100000
mod_gzip_item_include file \.htm$
mod_gzip_item_include file \.html$
mod_gzip_item_include file \.shtml$
mod_gzip_item_include file \.shtm$
mod_gzip_item_include file \.jsp$
mod_gzip_item_include file \.php$
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 ^server-status$
mod_gzip_item_include handler ^server-info$
mod_gzip_item_exclude file .css$
mod_gzip_item_exclude file .js$
#mod_gzip_item_exclude mime ^image/.*
mod_gzip_dechunk yes
mod_gzip_temp_dir /tmp
mod_gzip_keep_workfiles No
mod_gzip_can_negotiate yes
mod_gzip_send_vary Off
mod_gzip_item_exclude mime ^image/.$
mod_gzip_item_exclude mime ^image/
mod_gzip_item_exclude rspheader Content-Type:image/*
</IfModule>


Scroll down a bit future and find the AddModule section of httpd.conf. At the end, remove the mod_gzip line (commented out), and below all the AddModules, paste this:
AddModule mod_gzip.c

Save httpd.conf and exit the editor. Finally, restart Apache (/etc/rc.d/init.d/httpd restart).

You can check if your installation was successful by entering a URL at http://www.port80software.com/tools/compresscheck and seeing if it returns mod_gzip in the header.

Enjoy :).

sHuKKo
09-14-2003, 04:05 AM
I installed mod_gzip to my DA server using these instructions.
But there is something wrong after installation.
Everthing seems ok . Mod_Gzip is working but my IE6 + SP1 on my winxp pro is NOT caching images.

So I make some tests using this configuration Both Opera7 netscape and Mozilla caches images as expected. But IE6 + SP1 stops image caching after this configuration applied.

IE6 as usually downloads and puts a single big file in to temporary folder. But request images evertime from the server. As from the statistics of a sample site my users %90 uses IE 5+6 so there is no use of this configuration. Mod_gzip installed I use much more bandwidth than I try to save..

So I edited this config a little bit there is a problem with image mime stuff. I read form original config file of mod_gzip it says that you don`t have to include or exclude a full type but only add an mime type.



LoadModule gzip_module /usr/lib/apache/mod_gzip.so

<IfModule mod_gzip.c>
mod_gzip_on Yes
mod_gzip_minimum_file_size 300
mod_gzip_maximum_file_size 0
mod_gzip_maximum_inmem_size 100000
mod_gzip_item_include file \.htm$
mod_gzip_item_include file \.html$
mod_gzip_item_include file \.shtml$
mod_gzip_item_include file \.shtm$
mod_gzip_item_include file \.jsp$
mod_gzip_item_include file \.php$
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 ^server-status$
mod_gzip_item_include handler ^server-info$
mod_gzip_item_exclude file .css$
mod_gzip_item_exclude file .js$

mod_gzip_item_exclude file .jpg$
mod_gzip_item_exclude file .gif$

mod_gzip_item_exclude mime ^image/.*

mod_gzip_dechunk yes
mod_gzip_temp_dir /tmp
mod_gzip_keep_workfiles No
mod_gzip_can_negotiate yes
</IfModule>



does the trick for IE6+SP1 but I have got more than 60 left without caching in server image mime types..

Anyway this is something with mimetypes. But I did not have a all OK fix. So for now I stopped using mod_gzip.

I really want to know if someone dealt with this problem before..
If yes what is the correct config file for mod_gzip in apache 1.3.28 default DA installation..

TurtleBay
09-28-2003, 02:07 PM
Is there an answer for this yet? I'm concerned about trying to compress images...

Thanks,
John

loopforever
02-09-2004, 01:32 PM
I was just playing around with this, and I found the image caching fix with Firebird (haven't tested with IE yet).

When Firebird:

1) Reaches it's cache size limit or
2) Has already cached a page, but not the images...

It will refuse to cache the images. So, all you need to do is clear the cache in Firebird, reload the page, and it works :).

blueice
02-15-2004, 11:17 PM
Hi,
can inform the directadmin creators if it is stable to use modgzip?
I have bad expirience of cpanel with modgzip, so it is needed to be sure that modgzip can working fine with directadmin apache.
I use freebsd 4.9
Thanks a lot.
Regards,
Christos

DirectAdmin Support
02-16-2004, 09:44 AM
Hello,

I couldn't say if modgzip was stable or not, but I don't see why it wouldn't be. DA has no dependancy on any particular build of apache.

John

loopforever
02-16-2004, 12:36 PM
I've used it on a DA machine for about 8 months without any problems.

motobrandt
02-16-2004, 06:15 PM
I heard that there were problems with running mod_gzip and mod_ssl . Is anyone doing this. If so, have you had any problems?

I found THIS (http://216.239.37.104/search?q=cache:y_WjBD6KZ1gJ:lists.over.net/pipermail/mod_gzip/2002-February/005911.html+&hl=en&ie=UTF-8) but the date on it is almost 2 years ago. Is this still an issue?

cheers,
brandt

nebukazar
02-16-2004, 09:28 PM
Hi,

I am running RH 9.0 with apache mod_gzip + mod_ssl without any problems.

Peter
02-24-2004, 01:55 PM
I am not....

Alex04RL
03-30-2004, 12:19 PM
Ok,

I followed this How-to and it worked for webpages. My problem I'm having now is people can NOT download files via. a hyperlink. If they type in the address WITHOUT http:// it will work. ie. domain.com/file.exe will work... but http://domain.com/file.exe will NOT work. Any reason why this would be???

neorder
05-04-2004, 05:52 AM
is mod_gzip installed by default for the most recent DA? reason is because i found all my site already have gzip enabled.

i doubt this is necessary in the feature. am i right about it?

neorder
05-05-2004, 09:50 AM
okay, my question, how do i tell if mod_gzip is installed?

thanks a lot!

neorder
05-05-2004, 09:35 PM
i'm confused.

since we are going to install Mod_gzip, why

1. we need to find the mod_gzip line (commented out) and delete it.

are you referring this line in httpd?


#LoadModule gzip_module /usr/lib/apache/mod_gzip.so

2. where to add
AddModule mod_gzip.c ?

i've had this in my httpd

it's at the end of
# Reconstruction of the complete module list from all available modules

</IfDefine>
#AddModule mod_gzip.c

after i comments out this line, i can't restart my httpd, what's wrong with my setting?

neorder
05-05-2004, 09:47 PM
okay, i commenced out both lines

LoadModule gzip_module /usr/lib/apache/mod_gzip.so
AddModule mod_gzip.c

now httpd restarted, how can i check the performance? i've used these two:

http://www.desilva.biz/gzip-test.php
http://leknor.com/code/gziped.php

But before i install Mod_gzip, i found most of my pages are gzipped already, there is no imporvement after install Mod_gzip.

my question, do i recommand my users who run forums such as vbulletin or IPB to switch off their gzip?

nappa
06-05-2004, 03:08 AM
Has anyone had problems installing it according to this guide with the most recent DA ?

I've had a Cpanel servera long time, and I got DA with this new machine. I followed this guide, the one on i4net , the ones on Cpanel's forums, the ones on EV1 -- I couldn't seem to get it working with DA.

I got the following error.

-------------
Syntax error on line 1562 of /etc/httpd/conf/httpd.conf:
Invalid command 'SSLEngine', perhaps mis-spelled or defined by a module not included in the server configuration
-------------

When we took out all modgzip tags - things are fine.

So I would like to know if someone got something familiar to this recently. I need modgzip more than anything else. I don't ever use SSL, and I don't plan to host sites that need it either. So if someone can even tell me how tot totally remove that module, I wouldn't mind. Though I suspect my problem might be else where. We've not edited the httpd at all other than the changes that were specified in the guide in here.

nappa
06-06-2004, 02:22 AM
my question, do i recommand my users who run forums such as vbulletin or IPB to switch off their gzip?

Forum programs usually come with GZip activated. Don't tell them to turn it off, as in most cases the gzip is set to compress at CPU leve 1 - the minimal one. The Mod_Gzip has hard coded value of 6 - which saves you a few comre KB, but it uses a lot of CPU power comparatively to not make it worth it to be set that high. In the future versions they are going to let people select the compression level.

ModGzip is vastly helpful, when you've got lots of static pages. You will get around 70% in compression. IT will save you a lot of bandwidth. However, if you install it, you might be restriting your income, as your users can serve more pages, and use less bandwidth.

sander815
11-30-2004, 03:54 AM
is it possible to set the mod_gzip level to 1 instead of 6?

is this howto still uptodate?

nappa
11-30-2004, 04:05 AM
I used this guide about 1 month ago - no problems.

Chrysalis
11-30-2004, 08:10 PM
I might try this if someone knows a way to make it use compression level 1.

Daijoubu
12-01-2004, 04:31 PM
PHP's ob_gzhandler default compression level to -1 (6)
Change zlib.output_compression_level in php.ini to 1

Keep in mind gzipped html cannot be cached (at least in IE)
So if the page rarely updates, not gzipping the page would be best

I have a cron job who generate a new static page every 2 mins, doing 3 refresh within this timelaps using gzipped page (about 1KB each) would result in more bandwidth used than loading 3KB once

Chrysalis
12-01-2004, 04:48 PM
ok thanks

travelbuff
02-06-2005, 08:25 AM
Just a note - I had followed this how-to about 3 mos ago and it worked great. I left my zlib.output_compression_level at -1 and did not see noticable CPU drag but definitely noticed large text pages loading faster.

However, after updating DA to the latest version (1.23.3), gzip went away and I had to come back and do this again.

loopforever
03-30-2005, 11:20 AM
Hi Guys,

Glad to see so many people using this tutorial. It is rather old, as someone brought up, but it does still work.

I am about to update it a bit, because sometime over the last few months I did resolve the image caching issue - and I will revise the tutorial to include the proper configuration.

panamaspace
08-04-2005, 12:17 AM
File not available. :(

mod_gzip-1.3.26.1a.tgz?download&failedmirror=cogent.dl.sourceforge.net

Perhaps the topic can be updated to point to another file download location?

Thanx

panamaspace
08-04-2005, 12:57 AM
Dramatic speed improvement across my sites.

Every webmaster should do this.

I found the file at another file repository by doing a file search on Google.

Then followed the steps, and everything seems to work just fine.

Thanks

panamaspace
08-05-2005, 12:49 AM
As I said before, a dramatic speed/compression improvement in most of my pages.

I have a Miva website though, and it's output is not being compressed.

Any ideas?

Summary:
URL:

http://www.health-effects.net/Merchant2/merchant.m
vc?Screen=CTGY
Scope of analysis: Real-time data -- target file compression reports only (no supporting files).
Web server type:
Apache/1.3.31 (Unix) mod_gzip/1.3.26.1a mod_ssl/2.8.19 OpenSSL/0.9.7a PHP/4.3.8 mod_perl/1.27 FrontPage/5.0.2.2510
Compression status: Uncompressed

I have added

mod_gzip_item_include mime ^text/html$
mod_gzip_item_include mime ^text/plain$

to httpd.conf in an attempt to force it to compress, but no luck.

I looked high and low for help about this on Google, but couldn't find anything about that particular combination.

Any help is appreciated!

:confused:

ExoCrew
10-04-2005, 11:44 AM
Is it possible to do for only one VirtualHost / site ???

phantomk
10-07-2005, 12:56 PM
Worked like a charm :) Thanks for the guide.

sander815
10-09-2005, 04:47 AM
i am getting this error:

[root@server02 mod_gzip-1.3.26.1a]# make install
/usr/sbin/apxs -A -i mod_gzip.so
Configuration file is not valid. There are sections closed before opened.
make: *** [install] Error 1
[root@server02 mod_gzip-1.3.26.1a]#

anyone an idea?
I edited the makefile to /usr/sbin/apxs

Maniak
09-25-2006, 02:43 PM
I had problems while compiling mod_gzip today, some strange errors like this :


[root@server mod_gzip-1.3.26.1a]# make build
/usr/sbin/apxs -Wc,-Wall,-O3,-fomit-frame-pointer,-pipe -c mod_gzip.c mod_gzip_debug.c mod_gzip_compress.c -o mod_gzip.so
gcc -DLINUX=22 -DHAVE_SET_DUMPABLE -DNO_DBM_REWRITEMAP -DMOD_SSL=208128 -DUSE_HSREGEX -DEAPI -DUSE_EXPAT -I../lib/expat-lite -fpic -DSHARED_MODULE -I/usr/include/apache -Wall,-O3,-fomit-frame-pointer,-pipe -c mod_gzip.c
cc1: error: unrecognized command line option "-Wall,-O3,-fomit-frame-pointer,-pipe"
apxs:Break: Command failed with rc=1
make: *** [build] Error 1



I have changed the Makefile to this :


APXS?=/usr/sbin/apxs
RM=/bin/rm

build:
$(APXS) -Wc "-Wall -O3 -fomit-frame-pointer -pipe" -c mod_gzip.c mod_gzip_debug.c mod_gzip_compress.c -o mod_gzip.so

install:
$(APXS) -A -i mod_gzip.so

clean:
$(RM) -rf *.o

distclean: clean
$(RM) -f mod_gzip.so


then simply run as the howto.

Enjoy.

max2000
10-16-2006, 05:09 PM
Yes, this correction worked for me (Fedora 4, Apache 1.3.37 and PHP 4.4.4)

Thank you very much for having posted this.

jw00dy
12-27-2006, 01:27 AM
Thanks for the information.

Your suggested changes worked here too, though, I did not try it first without them.