How to install Google PageSpeed with Amazon ElastiCache



How to improve the page loading times on your website using Google mod_pagespeed module for Apache. The Google PageSpeed module can be set to use the Amazon ElastiCache for caching of files. This takes load of Ubuntu and lets you focus the memory to run Apache.


After installing the Google PageSpeed module open the config file:

sudo nano /etc/apache2/mods-available/pagespeed.conf

Scroll down to the section:

# If you want, you can use one or more memcached servers as the store for
# the mod_pagespeed cache.

Then add the address to your ElastiCache server.
Save the config file.
Restart Apache

sudo service apache2 restart

Change to Redis when it becomes available

Redis is a faster and better cache that memcache.

You shold change to redis when mod_pagespeed from Google starts to support Redis

Verify that PageSpeed works correctly

Your google page speed module has a web based reporting panel only available to localhost. You connect to the VPS server using SOCKS proxy through your SSHD server.

To access the Google page speed panel use the default HTTP:// access without SSL and the internal IP of you EC2 server.

The internal IP of your EC2  VPS server id displayed if you type


If the local IP of you EC2 VPS is you can access the PageSpeed panel on the address:


How to gain access to the PageSpeed panel

Check that you still have the HTML root folder

Check that you still have the default apache folder HTML

cd /var/www/
ls -a

If the necessary create the folder

sudo mkdir /var/www/html

For your reference create an index.html file

sudo nano /var/www/html/index.html

Tape some reference text in the file and then save it.

Then make sure that Apache can write to the folder

sudo chown www-data:www-data -R /var/www/html


Start the default port 80 Apache configuration

Every active Apache config file represents a potential entry point for the bad guys to your VPS. Every active Apache config drains your VPS server for memory. That is why only the config files you need should be active. In this case, you should activate the config file when you need to access the Google PageSpeed stats. Afterwards, disable the config file to block it as a possible entry point for bad guys and free up the resources.

To enable the config file:

sudo a2ensite 000-default.conf
sudo service apache2 restart

To deactivate the config file:

sudo a2dissite 000-default.conf
sudo service apache2 restart

Verify that you can access your server on port 80. If the local IP is, then you should be able to access the index.html file you have created in


by typing:

Don’t continue to the next step before this works

Allow the local IP to access Google PageSpeed panel

Open the page speed config file

sudo nano /etc/apache2/mods-available/pagespeed.conf

Use “Ctrl + w” to search for

Allow from

Then add the local IP for your EC2 VPS server.

If the IP is then this part of the config file would look like this:



 <Location /pagespeed_admin>
 Order allow,deny
 Allow from localhost
 Allow from
 Allow from
 SetHandler pagespeed_admin
 <Location /pagespeed_global_admin>
 Order allow,deny
 Allow from localhost
 Allow from
 Allow from
 SetHandler pagespeed_global_admin

Save the config file.

Restart Apache

sudo service apache2 restart

Connect to your VPS with VPN

Finally, connect to your EC2 VPS server using SOCKS proxy VPN.

The Google PageSpeed stats and info should now be able at:

[themedy_button url=”” icon=”wrench” font_awesome_att=”” label=”How to access your VPS through SOCKS VPN” colour=”blue” colour_custom=”” size=”large” edge=”rounded” target=”_self”]