Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to use AWS Beanstalk's .ebextensions config to install mod_pagespeed Apache module?

I'm using AWS Beanstalk for my Django/Python application, and I would like to use Google's mod_pagespeed module. Is it possible to install and run mod_pagespeed using the .ebextensions/.config file?

like image 515
man2xxl Avatar asked Apr 17 '13 17:04

man2xxl


2 Answers

Download the package

Add the rpm into your ebextensions directory

create a .config file in the .ebextensions directory

add commands to the config file like this:

container_commands:
    01-command:
        command:        rm -rf /pagespeed/ebextensions

    02-command:
        command:        mkdir -p /pagespeed/ebextensions

    03-command:
        command:        cp -R .ebextensions/* /pagespeed/ebextensions/

    04-command:
        command:        rpm -U /pagespeed/ebextensions/mod-pagespeed.rpm

Ensure the commands are indented as shown, with no tabs, otherwise it wont work.

swap "mod-pagespeed.rpm" for whatever the actual rpm file name is.

like image 63
Lawrence Cooke Avatar answered Jan 14 '23 04:01

Lawrence Cooke


Ok so I want to add Charlie Smith's answer. I would suggest you make sure you have the following things turned on.

  1. mod_deflate - You probably want to Gzip your html, css, xml, and javascript.
  2. Enable the rewrite domains filter in your Apache.conf if you use CDN (ex. AWS CloudFront)
  3. Set a short cache-control for images and css so pagespeed will be able to extend the cache when you turn on the extend_cache filter.
  4. I also like the rewrite_javascript, dns_prefetch, collapse_whitespace, and combine_javascript filters.

Here are the GitHub Gists that show you how its done.

  • The apache conf file
  • The Beanstalk container_commands (they are mostly the same as Charlie's)
like image 20
man2xxl Avatar answered Jan 14 '23 03:01

man2xxl