Introduction
In Linux systems, gzip (mod_deflate) is used to compress HTTP content before it is served to the client; this results in faster network transfers. However, simply having mod_deflate enabled is not enough to have your content compressed. In addition, gzip compression does not work with the CGI PHP handler, so you must select a different PHP handler to use it.
Procedure
- First, ensure that mod_deflate has been installed on the server by checking the installed Apache modules with the following command:
[root@host ~cPs]# httpd -M | grep 'deflate'
deflate_module (shared) - If the above command produces no output, the module is likely not installed. You can install it by accessing EasyApache in "WHM / Software / EasyApache 4"
- Under "Currently Installed Packages," click "Customize." Select "Apache Modules," search for "deflate," and tick the module on.
- Select "Review" to preview the install and then "Provision" to install the module. EasyApache will notify you when the installation is complete
- Once installed, you can enable mod_deflate in different ways depending on your needs. You can enable the module with rules in a website's htaccess file for user webpages. These can also be placed within the Apache Includes to affect all domains globally. You'll want to work with your website designer or System Administrator to ensure the rules you need are included. For a brief example, the following example compresses HTML, CSS, and Javascript text for faster access:
<IfModule mod_deflate.c> AddOutputFilterByType DEFLATE text/css AddOutputFilterByType DEFLATE text/html AddOutputFilterByType DEFLATE text/javascript AddOutputFilterByType DEFLATE text/plain AddOutputFilterByType DEFLATE text/xml </IfModule>
- PHP sites need to ensure they are not using the CGI handler to make use of mod_deflate. Navigate to "WHM / Software / MultiPHP Manager" and select a different handler for each version of PHP you wish to compress the data for.
- CMS scripts such as WordPress may not make use of the htaccess file for mod_deflate rules. These can often be enabled through plugins installed directly into the CMS software. Alternatively, they can be placed into an ini file. Navigate to "WHM / Software / MultiPHP INI Editor," select the version of PHP you wish to enable the module for and toggle "zlib.output_compression" to On.
Comments
0 comments
Article is closed for comments.