System Overview, host CentOS6.4 Apache2.4 php5.3.6 mysql5.5
Start: First verify that Apache has loaded the Mod_deflate module
1.httpd-m
In the results, see if there is a row of deflate_module (shared), if any, that the module has been successfully added. If you do not need to install the Load mod_deflate module first.
Confirm that your Apache version 2.0 has the Deflate module, that is, find the http.conf profile to find out if there is LoadModule deflate_module modules/mod_ Deflate.so is usually the default, remember that if there is "#" before the removal of the effective.
2 If this module is not in the list,
How to install the Load mod_deflate module.
The Mod_deflate module must be installed and loaded. Now describes how to install.
The control version found mod_deflate.c can be used command #find/-name mod_deflate.c Assume the path found is/home/cpeasyapache/src/httpd-2.2.23/modules/filters/ Mod_deflate.c
Then go to the/home/cpeasyapache/src/httpd-2.2.23/modules/filters/path, for example, execute/usr/local/apache/bin/apxs-i-c-a mod_ DEFLATE.C for installation (note that the Apache path installed for your source code is probably/usr/local/apache2.x.x/bin/), such as my path is/usr/local/apache/bin/). APXS command detailed instructions please Google! There's not much to say here.
Third: Find the httpd.conf configuration file, generally in two places 1./etc/http/conf/httpd.conf 2. /usr/local/apache/conf/httpd.conf is really not easy to find on the shell under the execution of #find/-name httpd.conf must be backed up before the modification is a very good habit.
IV: Edit the htppd.conf file at the end add the following code, you can vim + http.conf so that the cursor is automatically to the http.conf last line, copy the following code
<ifmodule mod_deflate.c> 6 addoutputfilterbytype deflate text/html text/ Plain text/xml application/x-httpd-php addoutputfilter DEFLATE css js </IfModule>
The above number 6 is to represent the compression ratio, HTML php CSS js These do not have to say that are based on your actual situation to choose to add.
Deflatecompressionlevel 9 refers to the level of compression, from 1 to 9, 9 is the highest level. It is understood that this can be reduced by up to 80% of the size of the transmission (depends on the contents of the file), at least to save half.
The Deflatecompressionlevel preset can use a value of 6 to maintain a balance between processor performance and page compression quality.
Add
As for the already compressed image format such as JPG, music files such as MP3, compressed files such as zip, there is no need to compress, because this file you open the server transfer compression, processor time will not run out, and even if you run, size is the same, if you use PHP functions such as compressed files, HTTPD service is not compressed again, system-level processing, always more efficient than the application level.
V: Finally, save exit, service httpd restart restart Apache Service
CentOS 6.4 Apache Open gzip method