Tips & Tricks
line

Custom platform for AWS Elastic Beanstalk - nginx, php 7.1, php-fpm, Google PageSpeed plugin and php-fpm caching platform on Amazon Linux

Custom platform for AWS Elastic Beanstalk - nginx, php 7.1, php-fpm, Google PageSpeed plugin and php-fpm caching platform on Amazon Linux

The challenge: AWS Elastic Beanstalk nginx php

Configure an nginxPHP 7.1PHP-FPMGoogle PageSpeed nginx plugin and PHP-FPM caching on AWS Elastic Beanstalk.

The solution: AWS Elastic Beanstalk Custom Platform

We created and deployed an AWS Elastic Beanstalk Nginx PHP Custom Platform. The custom EBS platform allows us to customise the operating system, installed software, scripts and other system configurations. The AWS EBS PHP platform comes with apache only, therefore we had to configure our own custom platform. The custom platform’s scripts can be found on our Github account here.

Be careful when selecting the AMI you would like to use for this custom platform because they differ from region to region. For this configuration, we used the ami-5652ce39 AMI and deployed the configuration for the Frankfurt region.

This custom AWS Elastic Beanstalk Nginx PHP platform has the following setup:

  • nginx 1.12.1;
  • PHP 7.1;
  • various PHP modules (check the 02-install-php.sh script for more details);
  • PHP-FPM 7.1;
  • Google PageSpeed nginx plugin (check the 03-install-ngx_pagespeed.sh script for more details);
  • PHP-FPM caching enabled;
  • nginx GZIP compression enabled.

Please consider the following aspects when using this AWS Elastic Beanstalk Nginx PHP custom platform:

  • both php-fpm and Google pagespeed plugin caches are deleted upon app deploy or app server restart;
  • depending on the EC2 instance type you use, please set appropriate values for the following php-fpm parameters: pm, pm.max_children, pm.start_servers, pm.min_spare_servers, pm.max_spare_servers (check php-fpm/www.conf);
  • the PHP memory limit is set to 512M (check php-fpm/www.conf);
  • logrotation is enabled for both nginx and php-fpm logs;
  • nginx and php-fpm EBS health checks work fine;
  • the cron service is restarted upon app deploy.

We will continue to update this custom EBS platform and release our modifications via Github.

For more details please feel free to contact us. We will be happy to help.