Page 1 of 1

How to enable G-Zip compression on apache2

Posted: Sat Apr 02, 2011 3:25 am
by Shaka
Good guys, this little guide will help to improve the speed of loading web pages on our site.

http://httpd.apache.org/docs/2.2/mod/mod_deflate.html

is very easy.

apache 2.2 server in our open our file configuration:

httpd.conf

find the line that says: mod_headers.so and mod_deflate.so
edit a line to enable the module, just remove a #
httpd.conf

Code: Select all

 LoadModule deflate_module modules/mod_deflate.soLoadModule headers_module modules/mod_headers.so 
add this line at end of file:

Code: Select all

 # G-zip / DeflateInclude conf/extra/httpd-deflate.conf 
save

Now create a file in the extra/httpd-deflate.conf

copy this code:
httpd-deflate.conf

Code: Select all

 <IfModule mod_deflate.c> AddOutputFilterByType DEFLATE text/htmlAddOutputFilterByType DEFLATE text/plainAddOutputFilterByType DEFLATE text/xmlAddOutputFilterByType DEFLATE text/cssAddOutputFilterByType DEFLATE text/javascriptAddOutputFilterByType DEFLATE text/x-jsAddOutputFilterByType DEFLATE application/xhtml+xmlAddOutputFilterByType DEFLATE application/xmlAddOutputFilterByType DEFLATE application/rss+xmlAddOutputFilterByType DEFLATE application/atom_xmlAddOutputFilterByType DEFLATE application/x-javascriptAddOutputFilterByType DEFLATE application/x-httpd-phpAddOutputFilterByType DEFLATE application/x-httpd-fastphpAddOutputFilterByType DEFLATE application/x-httpd-erubyAddOutputFilterByType DEFLATE application/javascriptAddOutputFilterByType DEFLATE image/svg+xml  # high 9 – low 1DeflateCompressionLevel 9 <IfModule mod_setenvif.c> # Insert filterSetOutputFilter DEFLATE # Netscape 4.x has some problems...BrowserMatch ^Mozilla/4 gzip-only-text/html # Netscape 4.06-4.08 have some more problemsBrowserMatch ^Mozilla/4\.0[678] no-gzip # MSIE masquerades as Netscape, but it is fineBrowserMatch \bMSIE !no-gzip !gzip-only-text/html # Don’t compress already-compressed filesSetEnvIfNoCase Request_URI .(?:gif|jpe?g|png)$ no-gzip dont-varySetEnvIfNoCase Request_URI .(?:exe|t?gz|zip|bz2|sit|rar)$ no-gzip dont-varySetEnvIfNoCase Request_URI .(?:avi|mov|mp3|mp4|rm|flv|swf|mp?g)$ no-gzip dont-varySetEnvIfNoCase Request_URI .pdf$ no-gzip dont-vary </IfModule> <IfModule mod_headers.c> # Make sure proxies don't deliver the wrong contentHeader append Vary User-Agent env=!dont-vary </IfModule>   # logs DeflateFilterNote Input instreamDeflateFilterNote Output outstreamDeflateFilterNote Ratio ratio LogFormat '"%r" %{outstream}n/%{instream}n (%{ratio}n%%)' deflateCustomLog logs/deflate.log deflate   </IfModule>
save

reboot our server apache.



reviewed in our deflate.log compression.

Code: Select all

 GET /icons/unknown.gif HTTP/1.1" -/- (-%)"GET /icons/blank.gif HTTP/1.1" -/- (-%)"GET / HTTP/1.1" 400/749 (53%)"GET / HTTP/1.1" 400/749 (53%)"GET / HTTP/1.1" 400/749 (53%)"GET / HTTP/1.1" 400/749 (53%)"GET / HTTP/1.1" 400/749 (53%)"GET / HTTP/1.1" 400/749 (53%) 
Test your website: http://www.whatsmyip.org/http_compression/

Re: How to Enable G-ZIP compression.

Posted: Sat Apr 02, 2011 10:47 am
by jurchiks
Interesting and valuable, thanks :)

Re: How to Enable G-ZIP compression.

Posted: Sat Apr 02, 2011 1:31 pm
by Shaka
and I tried and it works well.

logically copy, paste and test.

Re: How to Enable G-ZIP compression.

Posted: Thu May 12, 2011 5:17 am
by Shaka
updated, I forgot to fix the route logs and enable mod_headers.so

Re: How to enable G-Zip compression on apache2

Posted: Wed Mar 21, 2012 12:43 pm
by jurchiks
Bad trolling skills...
How are you posting this if you "can't go on the internet without it"?