Is it possible to use the AWS Beanstalk.ebextensions configuration to install the mod_pagespeed Apache module?

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

+8
apache amazon-web-services elastic-beanstalk mod-pagespeed
source share
4 answers

Download package

Add rpm to the ebextensions directory

create a .config file in a .ebextensions directory

add commands to the configuration file as follows:

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 

Make sure the commands are indented, as shown, without tabs, otherwise this will not work.

replace "mod-pagespeed.rpm" for any actual rpm file name.

+5
source share

Okay, so I want to add Charlie Smith's answer. I suggest you make sure that you include the following.

  • mod_deflate - You probably want to use gzip for html, css, xml and javascript.
  • Enable the rewriting domain filter in your Apache.conf if you are using a CDN (e.g. AWS CloudFront)
  • Set a short cache control for images and css so that movie pages can expand the cache when the extend_cache filter is enabled.
  • I also like rewrite_javascript, dns_prefetch, collapse_whitespace and comb_javascript filters.

Here are the GitHub Gists that show you how to do this.

+3
source share

Thanks guys! I got the job perfectly after your answer @ man2xxl.

You do not need to bind to the / pagespeed / extensions directory, but you can simply configure beanstalk.ebextensions:

 packages: yum: at: [] 10_setup_apache_for_mod_pagespeed: command: "cp enable_mod_pagespeed.conf /etc/httpd/conf.d" 20_install_mod_pagespeed: command: rpm -U -iv --replacepkgs mod-pagespeed-*.rpm 30_clear_mod_pagespeed_cache: command: touch /var/cache/mod_pagespeed/cache.flush 
+3
source share

You can install packages at the url. Therefore, you do not need to download and distribute RPMs. Something like this works:

 packages: rpm: pagespeed: https://dl-ssl.google.com/dl/linux/direct/mod-pagespeed-stable_current_x86_64.rpm files: "/etc/httpd/conf.d/zzzz-pagespeed-options.conf": mode: "00644" owner: root group: root encoding: plain content: | # put your pagespeed configuration here 

Note that I named the zzzz-pagespeed-options.conf file so that the httpd server loads it last.

Another advantage of this is that you really don't need to include any commands or worry about copying files on top and saving the files in the .ebextensions folder. You just update the file entry in the .config file.

+1
source share

All Articles