[Author: Zhang banquet this article version: V1.0 last modified: 2007.09.10 reprint please indicate the source: http://blog.s135.com]
1. If Apache is not installed. During compilation, add -- enable-Deflate. For example: (for Linux only, this step is not required for Windows)
./Configure -- prefix =/usr/local/Apache -- enable-Rewrite -- enable-so -- enable-Deflate
2. If Apache is installed. Add the mod_deflate module. For example: (for Linux only, this step is not required for Windows)
/Usr/local/Apache/bin/apxs-I-a-c/home/zhangyan/software/httpd-2.0.59/modules/filters/mod_deflate.c
Note:/home/zhangyan/software/httpd-2.0.59/is the Apache source code path.
3. After performing the preceding steps, a line is automatically added to httpd. conf: (remove the # At the beginning of the downlink for Windows)
Reference loadmodule deflate_module modules/mod_deflate.so
4. Edit httpd. conf and add:
Linux:
Reference <ifmodule mod_deflate.c>
Deflatecompressionlevel 9
Setoutputfilter deflate
# Deflatefilternote input instream
# Deflatefilternote output outstream
# Deflatefilternote ratio Ratio
# Logformat' "% R" % N/% N (% N %) 'deflate
# Customlog logs/deflate_log.log deflate
</Ifmodule>
Windows:
Reference <ifmodule deflate_module>
Deflatecompressionlevel 9
Setoutputfilter deflate
# Deflatefilternote input instream
# Deflatefilternote output outstream
# Deflatefilternote ratio Ratio
# Logformat' "% R" % N/% N (% N %) 'deflate
# Customlog logs/deflate_log.log deflate
</Ifmodule>
If you remove the # sign, you can view the number of bytes before and after the file is compressed in the logs/deflate_log.log file. For example:
"Get/index. html HTTP/1.1" 49373/276249 (17%)
The number of bytes before compression is 276249, the number of bytes after compression is 49373, and the compression ratio is 17%.
5. For detailed configuration, see apache Official Website: http://httpd.apache.org/docs/2.0/mod/mod_deflate.HTML