enable the Apache deflate module to turn on compression and reduce bandwidth when the website is transmitted.
Apache needs to compile the installation mode, to/usr/local/apache for the Apache installation directory, the source package/usr/local/src/httpd-2.4.33 as an example
First View/usr/local/apache/bin/apachectl-m # # #查看里面的模块是否有deflate模块, you can also filter/usr/local/apache/bin/apachectl-m | grep deflate
If there is a httpd.conf under the open, if not shown, or with grep filtered after the display syntax OK, the module is not installed.
Compile and install the Deflate module in Dynamic shared module mode (DSO)
/usr/local/apache/bin/apxs-c-i-a/usr/local/src/httpd-2.4.33/modules/filters/mod_deflate.c #其中前面部分是安装好的apache软件里面的apxs程序, behind the deflate compression module in Apache's Source installation package
APXS Program Compilation options:
-C means to perform a compile module operation
-I means performing the install module operation
-a means to automatically add a loadmodule line to the httpd.conf file to activate the module
When the installation is complete, see if the module is installed and activated in vi/usr/local/apache/conf/httpd.conf
LoadModule Deflate_module modules/mod_deflate.so
<ifmodule mod_deflate.c>
Deflatecompressionlevel 9 # # #压缩等级 (1-9), the higher the level of efficiency, but also the high CPU consumption, according to the specific situation tuning, can also be set to 6来 balance CPU and compression quality
Setoutputfilter DEFLATE
Deflatefilternote Input instream
deflatefilternote Output OutStream
deflatefilternote Ratio Ratio
Addoutputfilterbytype DEFLATE text/html text/plain text/xml text/css
Application/javascript # #仅压缩限制特定的MIME类型文件
</ifmodule>
Apache Tuning Open Deflate Compression module