CentOS 7 Apache 2.4 开启Gzip压缩配置

CentOS 7 Apache 2.4 开启Gzip压缩配置

  1. 首先查看是否启用以下三个模块

    vim /etc/httpd/conf.modules.d/00-base.conf
    LoadModule deflate_module modules/mod_deflate.so
    LoadModule headers_module modules/mod_headers.so
    LoadModule filter_module modules/mod_filter.so
  2. 增加配置文件

    vim /etc/httpd/conf.d/gzip.conf

    写入

    AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript application/javascript
    DeflateCompressionLevel 9

    或者写入

    <filesMatch "\.(js|html|css)$">
     SetOutputFilter DEFLATE
    </filesMatch

标签: apache centos gzip linux

发表评论: