How to run Ultra-Fast WordPress on Http/2 with ALPN, WP-Rocket and AWS CloudFront on AWS and RHEL

Computing

Introduction

A website is a mirror of his/her owner. If one’s website is too slow, maybe the owner does not care about pushing the limits in all his/her other endeavors.

The steps below outline the instructions how to set up the one of the fastest possible WordPress installations at the moment.

Disclaimers

  • Neither AWS, nor RedHat does provide any support for these installation steps. If you require support, contact Jiri to discuss his availability.
  • These instructions are a result of years of experience, extensive web research and countless conversations with various brilliant people. Their help is much appreciated.
  • The packages discussed below are cutting-edge, and they are not yet part of RedHat Enterprise Linux (RHEL) or AWS Linux. If you prefer, you can download them already built from either Remi’s Repo or Webtatic provided you trust these repositories. For production environments, I strongly advise against that due to a chance of trojan horses etc. being included in the built versions.

Target Infrastructure

I build all my systems on AWS because I found their level of service unmatched by services of any other cloud provider.

I use RedHat Enterprise Linux because

  • it’s well supported
  • it’s a stabilized version of Fedora Linux and some time ahead of the default AWS Linux
  • I can easily test the installation steps on a local dev machine with VMWare Workstation’s RHEL image with snapshots which I found to be the most effective ways of fine-tuning production systems

The below instructions should apply with minor modifications to other Linux versions.

Http/2

Http/2 is a performance boosting update to the 1999’s http 1.1 protocol used for all web traffic.

In a nutshell, it utilizes only a single multiplexed connection to the server (opening of a connection channel takes most of the web page loading time), it’s binary, it prioritizes the order of resources being delivered, and pushes to the client pro-actively the resources it may request in the future.

It’s already supported by majority of web browsers – at the time of writing this article in January 2017 it was 78%.


Thus, by your website not supporting the protocol, your audience spends unnecessarily more time on its loading, and in consequence being less satisfied.

OpenSSL, Apache, PHP Setup

0. Set Up RedHat

Enable RedHat Repositories:

Change enabled=0 to enabled=1

Install the prerequisites:

1. Upgrade OpenSSL

2. Apache

Uncomment these lines

Add these lines

Change Override None to Override All

Backup SSL settings

Change these values for these parameters:

  • ServerName
  • ServerAdmin

Uncomment the parameter SSLCertificateChainFile.

Upload the SSL certificates to the appropriate locations

Restore permissions

Reboot, log back in and check all apache configs are fine

Set up auto-start of Apache

Paste there this text:

Run

Set up permissions for www

Reboot to see if the Apache was started automatically

3. PHP

Uncomment

Add

Set up PHP’s settings

Paste there this text

Install ImageMagick

Add there these policies, if they are not already present

Reboot and restore the original WordPress site from BackupBuddy.

4. Final Check

Go to https://tools.keycdn.com/http2-test and check your website does run on Http/2 with ALPN:

WordPress Setup

I highly recommend the below two WordPress plugins for enhanced WordPress performance.

In addition, I strongly recommend manual running of the WordPress’s Cron.

1. WP-Offload

WP-Offload is a WordPress Plugin uploading all media (images, videos and others) into an AWS S3 bucket which is then mapped onto an AWS CloudFront distribution serving as a super-fast CDN.

Recommendation: Do enable Http/2 on the AWS CloudFront Distribution.

2. WP-Rocket

WP-Rocket is one of the best page caching / pre-loading plugins available.

It minifies CSS, JS files, offers lazy loading of images or video, and stores pre-generated html pages in a cache so that whenever the web server receives a page request, it can be served without the server having to build it from its MySQL representation.

And above all, it’s exceptionally well supported.

Advertisements
Menu