无法在 Apache (FreeBSD) 中启用 Gzip 压缩

Cannot enable Gzip compression in Apache (FreeBSD)

我在 Apache 服务器 (FreeBSD) 上使用 Gzip 压缩时遇到问题。在我的 httpd.conf 文件中我有:

ServerRoot "/home/xxxx-strona"
Listen 10.0.1.240:55734
PidFile /home/xxxx-strona/NOBACKUP/pid
Mutex default:/home/xxxx-strona/NOBACKUP
StartServers 1
MinSpareServers 1
MaxSpareServers 1
LoadModule mpm_prefork_module /usr/local/libexec/apache24/mod_mpm_prefork.so
LoadModule authn_core_module /usr/local/libexec/apache24/mod_authn_core.so
LoadModule authz_core_module /usr/local/libexec/apache24/mod_authz_core.so
LoadModule unixd_module /usr/local/libexec/apache24/mod_unixd.so
LoadModule reqtimeout_module /usr/local/libexec/apache24/mod_reqtimeout.so
LoadModule log_config_module /usr/local/libexec/apache24/mod_log_config.so
LoadModule setenvif_module /usr/local/libexec/apache24/mod_setenvif.so
LoadModule dir_module /usr/local/libexec/apache24/mod_dir.so
LoadModule mime_module /usr/local/libexec/apache24/mod_mime.so
LoadModule alias_module /usr/local/libexec/apache24/mod_alias.so
LoadModule rewrite_module /usr/local/libexec/apache24/mod_rewrite.so
LoadModule expires_module /usr/local/libexec/apache24/mod_expires.so
LoadModule headers_module /usr/local/libexec/apache24/mod_headers.so
LoadModule filter_module /usr/local/libexec/apache24/mod_filter.so
LoadModule deflate_module /usr/local/libexec/apache24/mod_deflate.so
LoadModule php7_module /usr/local/libexec/apache24/libphp7.so
LoadModule php7_module /usr/local/libexec/apache24/mod_http2.so

ServerAdmin xxxx
ServerName www.xxxx.pl
DocumentRoot "strona"
<IfModule dir_module>
    DirectoryIndex index.html index.php index.php3 index.cgi
</IfModule>
<Directory />
 AllowOverride All
</Directory>
<FilesMatch "^\.ht">
Require all denied
</FilesMatch>
#ErrorLog "NOBACKUP/httpd-error.log"
ErrorLog "/dev/null"
LogLevel warn

<IfModule log_config_module>
    LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
#    CustomLog "apache/httpd-access.log" combined
 CustomLog "/dev/null" combined
</IfModule>

<IfModule mime_module>
    TypesConfig /usr/local/etc/apache24/mime.types
    AddType application/x-compress .Z
    AddType application/x-gzip .gz .tgz
    AddHandler cgi-script .cgi .pl
    AddType application/x-httpd-php .php .php4 .php3
    AddType application/x-httpd-php-source .phps
</IfModule>
EnableSendfile off

<IfModule mod_deflate.c>
    <IfModule mod_filter.c>
        # these are known to be safe with MSIE 6
        AddOutputFilterByType DEFLATE text/html text/plain text/xml

        # everything else may cause problems with MSIE 6
        AddOutputFilterByType DEFLATE text/css
        AddOutputFilterByType DEFLATE application/x-javascript application/javascript application/ecmascript
        AddOutputFilterByType DEFLATE application/rss+xml
        AddOutputFilterByType DEFLATE application/xml
        AddOutputFilterByType DEFLATE image/svg+xml
    </IfModule>
</IfModule>

<Directory /home/xxxx/xxxx-strona2/strona/>
php_admin_value upload_tmp_dir /home/xxxx-strona/NOBACKUP
</Directory>

但我仍然收到错误消息:

We successfully added Gzip compression settings into .htaccess file. However, the test file we fetched was not Gzip-compressed. It seems one of Apache modules - mod_filter or mod_deflate - is not active.

(WP 优化插件)

GTmetrix 还说 Gzip 未启用。

错在哪里?

服务器版本问题。