Hire Magento 2 developers (up to 5 years exp, Magento 2 experience since beta release) Contact us now!


Ultimate Magento performance guide: Nginx+http/2+PHP 7.0.8

Magento http2

Performance is very important for both community and enterprise level Magento projects. To speed up our customer’s stores we are always using the latest technologies. In this article, I will explain you why do we use Nginx+http/2+PHP 7.0.8 server technology stack and how it influences the performance of Magento shops. This article was meant to show that if you don’t want to spend much money on upgrading your VPS plan or installing heavy caching systems like Varnish, Memcached etc. there are simple solutions which could help to speed up your web shop significantly.


Magento Http2

The HTTP/2 specification was published as RFC 7540 in May 2015, so this technology is quite new. The new version of protocol minimizes the number of requests required to render an entire page by reducing the amount of code, without reducing its ability to function. It influences web-site resources such as images and scripts. HTTP/2 allows the server to “push” content, that is, to respond with data for more queries than the client requested. This allows the server to supply data it knows a web browser will need to render a web page, without waiting for the browser to examine the first response, and without the overhead of an additional request cycle. This technology allows users to reduce the number of requests and also sends and receives them faster.

Giants like Google, Facebook, Instagram already use HTTP/2.0 to serve content. By the way, our website already supports http/2.0 If you want to check whether your web shop has the support of the new HTTP protocol version – there is a beautiful chrome extension for that.

Basic requirements for http/2.0:

  • Apache or Nginx website built with http/2.0 module
  • SSL certificate (HTTPS enabled)


magento2 and nginx

Nginx is a technology that helps you to serve HTTP requests. Nginx uses an asynchronous approach for handling the requests and has a modular system, which is often more predictable under high loads and is very good in balancing.

I would recommend you using Nginx as it is much easier to enable http/2.0 in the latest Nginx version than doing it in Apache 2.4.

In this guide, I will use Ubuntu as an example as we find ubuntu the fastest Linux VPS distribution in terms of performance.

To enable http/2 in nginx you need to:

To check if you have http/2 support enabled – type the following command:

In the output of this command you need to find the following line:


Next, you need to add the http/2 support in your nginx vhosts files. In order to do that, you need to edit:

and change:


After saving the changes – you need to reload nginx:

Please note: This article assumes, that you have already purchased and enabled the ssl certificate at your VPS.

P.S.: If you are using Apache2.4 and Ubuntu for your VPS – enabling HTTP/2.0 is really easy:

Then in your vhost config add the following:

One more thing: It is impossible to use HTTP/2 in Nginx as a reverse proxy mode. You should either change Apache to PHP-FPM (or other application back-end server) or install Apache with HTTP/2 support.


php7 Magento 2

PHP 7 is also quite a new version of a popular programming language PHP. It is twice as fast as the last version – PHP 5.6. I will not go into details of the differences between PHP 5.6 and PHP 7, but for high-load magento  projects. I would definitely recommend the PHP 7. By the way, Magento 2.1 has a support of PHP 7 out of the box. If you are still running Magento 1.x and want to migrate to PHP 7 – there is a great community built the extension that provides a support of the latest PHP version. You can find it here.

To install PHP 7 add the following repo:

Then install PHP7 and required extensions for running Magento:

PHP7-FPM as an application server

When I first wrote this article, I didn’t realize that for most of you, it’s not obvious how to install the back-end server for your web application. As an example, I will give you the guidance on how to configure PHP7-FPM together with Nginx.

First, you should install PHP7-FPM:

Next, add the following lines to your virtual host configuration file (inside the server{ } directive), which is located in /etc/nginx/sites-enabled/


This article might be a useful advice for those of you who has a small-medium business and searching for a better performance without spending huge budgets on infrastructure. Sometimes, it’s enough to use the latest technologies to speed up websites. By following instructions from this guide you can speed up your Magento store 4x times without spending big budgets on upgrading a VPS plan.

In the next article, I will explain, you how to speed up your Magento store 50x times with the help of Varnish cache to achieve the enterprise level performance grades.

Frequently Asked Questions:

  • What about the database? How do I configure this for Magento?The configuration of MySQL depends on your VPS specs, so I wouldn’t give any specific recommendations in this article. The two main points regarding this are:
  1. Use PERCONA CONFIGURATION WIZARD FOR MYSQL for configuring MySQL properly
  2. Use MariaDB or Aurora/MySQL from AWS as a MySQL engine
  •  What caching strategy should I use? This topic will be covered in the next article
  •  What about reconfiguring the system resources? – This topic will be covered in the next article
  •  How do I correctly size my server? – This topic will be covered in the next article


Pavlo Okhrem
Article by Pavlo Okhrem

CEO/Co-founder at eLogic Commerce. E-commerce expert. International conferences speaker.