Enable mod_deflate on AWS Elastic Beanstalk
mod_deflate module for Apache on AWS Elastic Beanstalk can be quite challenging as the environments fine tuning currently is not possible via web console yet. Luckily AWS provides some other clever ways that allows us to perform advanced configuration for Elastic Beanstalk deployments via
.ebextensions (Elastic Beanstalk Extensions). By using these extensions we can perform almost any kind tweaks in terms of software for each individual environments that we have within our EB Application. In this short tutorial we will guide you, step by step as usual how to enable and configure
mod_defalte module for Apache using
.ebextensions for your AWS Elastic Beanstalk Environment.
Table of contents
Preparing the environment file
On our very first step we have to make sure that the necessary folder and file for our solution are in place:
$ cd /to/your/application/folder $ mkdir .ebextensions $ cd .ebextensions $ touch mod_deflate.config
Writing mod_deflate.config file content
On this step we have to edit our
mod_deflate.config file like shown in the example below. Please pay attention to indentation as
.config files present within .ebextensions are treated as
.yml (YAML) files. We can have as many files needed for different modules, tweaks or packages but on this tutorial we will resume to only present
enable_mod_deflate.conf to Apache. So let’s open and edit
mod_deflate.config file and add the following lines:
Once the lines were added please just close the file and let’s move to our next and final step.
Packing and deployment
On this final step we have to compress the application files and folders and also to perform a deployment that now contains a
.ebextensions folder and also a configuration file for our
mod_deflate Apache module:
$ cd .. $ zip -r my-application.zip * .[^.]*
Once the zip file is created please upload it to your Application and deploy it to your preferred environment in order to take effect.
Sometimes by simply deploying the new application version containing
.ebextensions won’t enable or perform the changes specified within
.config files and then we have two solution, first being to restart AWS Elastic Beanstalk Environment and if this fails then the second solution will be to rebuild the environment. If any of these fails please double check the indentation from
.config file as these type of files are treated as
.yml (YAML) files.