How to enable gzip compression in Apache on Plesk server?

Follow

Comments

20 comments

  • Avatar
    Mattia Gregolin

    Thank you. This was very helpful for my Amazon Ec2 instance!

    1
    Comment actions Permalink
  • Avatar
    Deyvi Arellano

    Disculpa pero cuando realizo lo siguiente me deja de funcionar apache! 

    0
    Comment actions Permalink
  • Avatar
    Alexandr Tumanov

    @Deyvi,

    Could you please share the information about the error? Apache version? The article was verified and no errors with apache were found.

    0
    Comment actions Permalink
  • Avatar
    Gianluca (Edited )

    Please correct the row number two on the ssh code section:

    # Compress HTML, CSS, JavaScript, Text, XML and fonts AddOutputFilterByType DEFLATE application/javascript

    0
    Comment actions Permalink
  • Avatar
    Ivan Postnikov

    Hello @Gianluca,

    Thank you for noticing. The article was updated.

    1
    Comment actions Permalink
  • Avatar
    Jan Bludau

    @Ivan:

    there should be an option in plesk to do that serverwide alone...

    per domain a "infobox" where you can grab the needed code

    1
    Comment actions Permalink
  • Avatar
    Dinara Tsydenova (Edited )

    Hello @Jan Bludau,

     

    >there should be an option in plesk to do that serverwide alone...

    Take part in our product improvement and vote for this feature on Plesk UserVoice. The top-ranked suggestions are likely to be included in the next versions of Plesk.

    As for "infobox" could you please share the details and clarify the usecase?

    0
    Comment actions Permalink
  • Avatar
    Marco Marsala

    On my server I didn't do such configuration, I don't have such files, but all replies are still compressed (HTTP Response Header contains Content-Encoding: gzip).

    0
    Comment actions Permalink
  • Avatar
    Alisa Kasyanova

    @Marco Marsala
    Have you checked this article as well: https://support.plesk.com/hc/en-us/articles/213380049 ? If sites are using WordPress, there could be plugins that enable gzip compression.

    0
    Comment actions Permalink
  • Avatar
    Nerque

    When you enable the gzip option in apache, do you need to enable it in nginx as well, or do you have to choose between the two? I'm saying this because I think it's usual to have nginx as an apache proxy.

    0
    Comment actions Permalink
  • Avatar
    Maxim Krasikov

    Hi @Nerque,

    Since Nginx is used as an Apache proxy, gzip compression should be enabled for Nginx and disabled for Apache. In this configuration, static files are served by Nginx.

    Information on how to enable compression for Nginx can be found here:
    https://support.plesk.com/hc/en-us/articles/213380049

    1
    Comment actions Permalink
  • Avatar
    Nerque (Edited )

    Thanks @...

    The truth is that I'm still in doubt, due to the nginx option of "Serve static files directly by nginx".

    In my case, nginx is used as a proxy (it is enabled) but the commented option is disabled, due to the accompanying note "Caution: Apache rewrite rules will not be applied."

    I have several Prestashop web pages that use rewrite rules, so I guess I can't enable the commented option. So, who really serves the static content?

    It's pretty confusing how to set these parameters... I don't understand how I can use nginx as a proxy and have the option "Serve static files directly by nginx" disabled by default... Even more confusing is that it warns of problems if enabled in case of apache rewrites.

    And for this reason I don't know if compression should be enabled in nginx or in apache...

     

    0
    Comment actions Permalink
  • Avatar
    Pavel Rozental

    Hello,

    If "Smart static files processing" and "Serve static files directly by nginx" checkboxes are not enabled - both static and dynamic content are served by Apache
    If "Smart static files processing" or "Serve static files directly by nginx" are enabled - statick content is served by Nginx.
    You can check documentation for more details: https://docs.plesk.com/en-US/obsidian/administrator-guide/website-management/websites-and-domains/hosting-settings/web-server-settings/apache-and-nginx-settings.72320/

    Note: .htaccess is not used If "FPM application served by nginx" is selected in  "PHP Settings".

    In case of "FPM application served by Apache" is set in "PHP Settings" and option "Smart static files processing" is selected - .htaccess file will be used by Apache:

    https://docs.plesk.com/en-US/obsidian/administrator-guide/web-servers/apache-and-nginx-web-servers-linux/adjusting-nginx-settings-for-virtual-hosts.71997/

    0
    Comment actions Permalink
  • Avatar
    Nerque (Edited )

    Thanks @...

    "Smart static files processing" Enabled

    "Serve static files directly by nginx" disabled

    So I guess, from the article you're talking about, I'm in the "Serve all static content via nginx".

    About .htaccess, I'm sure they're all applied correctly.

    With this situation, I guess from what I've read around here, that the best option is to enable the gzip options in nginx.

    But still, if I use the pagespeed module... What? Pagespeed with apache and gzip in nginx? Pagespeed and gzip in nginx?

    As far as I know, if I activate the pagespeed module in apache, then I need to disable the "smart static", and all the static content will be served by apache. So I guess in this case gzip must be in apache.

    If I activate Pagespeed in nginx, I don't know if it will be fully compatible with this context. And I don't know if Plesk works as well with this module activated in nginx, as it can if I activate it in apache.

    However, if I activate Pagespeed, I may not need to activate the gzip and I'm just fooling around.

    Many pieces to this puzzle and I can't find a place that deals with all these issues together. That's why all my doubts.

    I will try to extrapolate the reference I found in the Plesk forums (https://dh42.com/blog/fastest-prestashop/) on all this. But I will have to fight with the things that have changed in the last years, with the possibilities of Plesk, and with the context of nginx as a proxy and apache to serve a dynamic content.

     

     

     

     

    0
    Comment actions Permalink
  • Hi Nerque,

    If you want to use Pagespeed module, then you must use Apache or nginx, as it's available for both webservices.

    Plesk's Pagespeed module isn't configured from Plesk, the only possibility is to enable or disable it, further configuration has to be done from your side.

    Apart from that, the choice is on your side: to use nginx, apache, or nginx+apache.

    0
    Comment actions Permalink
  • Avatar
    SergioEA

    Hi,

    I have 'deflate' and 'filter' modules enabled, updated the .htaccess file using Plesk interface, but tools.pingdom.com replies that GZIP it is not enabled.

    I work with Wordpress (https://icadministraciongeneral.com)

    Thank you.

     

    0
    Comment actions Permalink
  • Hi SergioEA,

    As far as I see (with CURL), the domain is using already GZIP.

    0
    Comment actions Permalink
  • Avatar
    fatimah alqadheeb (Edited )

    I could not find the Apache Web Server or Apache & Nginx Settings in my Plesk control panel and I am an administrator user. I am using PHP with Plesk version 18.0.33 and IIS server setting 

    0
    Comment actions Permalink
  • Avatar
    Bulat Tsydenov

    Hi fatimah alqadheeb

    Apache web server is not available in Plesk for Windows, IIS is used instead. Therefore here is the right article:

    https://support.plesk.com/hc/en-us/articles/115000209874-How-to-configure-compression-and-caching-in-Plesk-on-Windows- 

    0
    Comment actions Permalink
  • Avatar
    Robert Alexander

    I've got WP optimise setup on the domain of my server.
    I want to enable GZIP server wide using SSH as advised on this topic.
    I've done all the checks and followed the instructions and I am receiving this message from the Plugin.

    We successfully added Gzip compression settings into .htaccess file. However, the test file we fetched was not Gzip-compressed. Possible causes include that Apache (your webserver) is not configured to allow .htaccess files to take effect, or one of Apache modules - mod_filter or mod_deflate - is not active, or the webserver is configured to disallow Gzip compression. You should speak to your web hosting support to find how to enable it.

    The only error I get using SSH is this, and it may be the reason why I can't get GZIP enabled.
    [root@server ~]# grep -ir "mod_filter.so" /etc/httpd/conf.modules.d/00-base.conf

    LoadModule filter_module modules/mod_filter.so
    [root@server ~]# LoadModule filter_module modules/mod_filter.so
    -bash: LoadModule: command not found

    However, now I don't know what else I can do, so that the filter module is found. It's definitely enabled on the Server

    0
    Comment actions Permalink

Please sign in to leave a comment.

Have more questions? Submit a request