29

I am using xampp sever latest version to improve my web page performance.

I have to enable Gzip in XAMPP. How can it be done?

Boaz
  • 19,892
  • 8
  • 62
  • 70

4 Answers4

62

You do compression by setting appropriate directive in apache.

It goes uncommenting the following lines in your apache conf file: C:\xampp\apache\conf\httpd.conf

if your xampp installation folder is C:\xampp.

and these are the lines to be uncommented first:

LoadModule headers_module modules/mod_deflate.so
LoadModule filter_module modules/mod_filter.so

that is to say, if they have # before them, you should remove them!

Then put this at the end of your httpd.conf file:

SetOutputFilter DEFLATE 

<Directory "C:/your-server-root/manual">  #any path to which you wish to apply gzip compression to!
    <IfModule mod_deflate.c>
        AddOutputFilterByType DEFLATE text/html  # or any file type you wish
    </IfModule>
</Directory> 
linuxeasy
  • 6,269
  • 7
  • 33
  • 40
  • How do you set up the directory path if you've a virtual host set up? –  Nov 17 '12 at 04:10
  • @idb You can have this `SetOutputFilter` and ` – linuxeasy Nov 19 '12 at 07:26
  • 3
    The line `AddOutputFilterByType DEFLATE text/html` makes xampp not start up. **Edit** using `` around it it does work. – jdepypere Aug 17 '13 at 11:46
  • @arbitter it worked for OP, may be issue with different versions. – linuxeasy Aug 17 '13 at 13:04
  • 5
    For Apache 2.4 you also need to uncomment `LoadModule filter_module modules/mod_filter.so` as this is required for mod_deflate to work. Also, you may want to check that mod_deflate is enabled by wrapping your output filter calls: ` AddOutputFilterByType ... ` – jxmallett Apr 14 '14 at 00:07
  • For me, only with add SetOutputFilter DEFLATE , worked. – Aby W Feb 28 '16 at 14:26
  • If you have ` ... ` tag in your .htaccess file of your website(s), you don't need this ` ... ` tag in httpd.conf – evilReiko May 22 '16 at 06:44
  • 1
    Why do you have headers_module for mod_deflate.so? I see deflate_module modules/mod_deflate.so in my conf. Is this a typo of yours? – Andrew Oct 15 '16 at 06:14
15

Everything what is said above does not work on my XAMPP version 1.8.1 (php 5.4.7).

The only thing that works is to put on "On" instead of "Off" these line of the php.ini file:

zlib.output_compression = On
luciole135
  • 166
  • 1
  • 4
  • 5
    In Apache 2.4 (included in XAMPP 1.8.1), you also need to enable `mod_filter` for `mod_deflate` to work. See my comment on the accepted answer. With this done there should be no need to enable zlib (I'm honestly not entirely sure what zlib does). – jxmallett Apr 14 '14 at 00:10
9

Find apache\conf\httpd.conf

uncomment the following line(remove #)

LoadModule headers_module modules/mod_deflate.so

some versions may require you to comment out the following lines instead.

LoadModule headers_module modules/mod_headers.so
LoadModule deflate_module modules/mod_deflate.so

finally add this line to your .htaccess file.

SetOutputFilter DEFLATE
TarranJones
  • 4,084
  • 2
  • 38
  • 55
  • Just a pointer: all as above, just I put SetOutputFilter DEFLATE into httpd.conf at the end. – Jeffz Apr 28 '18 at 22:01
0

Not sure why you have this code:

LoadModule headers_module modules/mod_deflate.so

But that didn't work for me, it returned an APACHE error on Apache/2.4.3 (Win32):

12:57:10  [Apache]  Error: Apache shutdown unexpectedly.
12:57:10  [Apache]  This may be due to a blocked port, missing dependencies, 
12:57:10  [Apache]  improper privileges, a crash, or a shutdown by another method.

I Had to use:

LoadModule deflate_module modules/mod_deflate.so
  • the key was to uncomment the line. Different apache installations(ubuntu, centos, wamp, xampp) may have different configurations. – linuxeasy Jul 02 '13 at 08:40