Give us a call: +(1) 269 252 4193
Select your language
How to make your website load in under 2 seconds using Apache, Nginx, Redis, PHP7, MySQL, and WordPress

How I Got My Pages to Load in Under 2s*

April 2, 2018 | By admin | Filed in: hosting.

*Your speed times will probably vary, depending on your location, internet connection speed, etc.

My Results

I started out with the goal of getting my websites to load as quickly as possible (even without using a CDN). After a lot of research, trial-and-error, and development, I created the following combination for an efficient web server. The net result is load times under 2 seconds for my entire WordPress-based homepage:

Potent Pages' Loading in Under 2s: Pingdom

Potent Pages’ Homepage Loaded in 775ms according to Pingdom.

Potent Pages' Loading in Under 2s: GTmetrix

Potent Pages’ Homepage Loaded in 1.2s according to GTmetrix.

Why You Need Quick Load Times

Getting a website to load quickly is one of the most important aspects of website design. Your website doesn’t count for much if your visitors aren’t able to look at your page or have already left because it loads too slowly. So, it’s important to get your website as quick and efficient as possible to your visitors.

According to research by kissmetrics, 47% of visitors expect a web page to load in 2 seconds or less. Even worse 40% abandon a website that takes longer than 3 seconds to load. Emphasizing load times importance, 79% of shoppers who are dissatisfied with a website’s performance are less likely to buy from the same site again. Finally 52% of online shoppers state that fast page loading time is important to their loyalty to the site.

So quick load time is essential to satisfied customers and achieving high conversion rates. But how best can we go about this? Most people end up using Apache as their primary web server and simply serve their site directly from a shared hosting platform. According to w3techs.com, “Apache is used by 47.2 %” of known web servers. While this is usually economically less expensive, this can end up costing a lost opportunity.

Apache Is Great For…

Apache is great at handling server-side scripting, such as PHP, and for serving multiple sites at the same time. It’s relatively straightforward to configure and includes useful tools like htaccess files. Unfortunately though it can be a bit slow. Apache is designed for fewer connections and is slower to process those connections because the scripting languages are loaded every time. This slows things down. So while Apache is great for serving dynamically generated content directly (because the language interpreter is loaded befo?rehand) it can be slower when serving static content. But there is a faster way for static files.

Nginx Is Better For…

Enter nginx. Nginx is like the mirror image of Apache. While Apache is great for dynamic content, Nginx is ideal for static content. In fact everything about nginx is designed for serving static content as quickly and as efficiently as possible. Nginx doesn’t even contain in-built support for scripting languages such as PHP or python. This makes it faster and more memory-efficient for serving static files. Instead you’ll have to manually configure these to allow for dynamically generated content. So you can configure nginx to work as a standalone server and many people do…

…but what if there was a way to combine Apache and nginx together?

Combining Them Together

Instead of simply serving either dynamic content quickly and having to manually configure all of the PHP administration, what if we could simply have nginx serve static content and then for all Dynamic content simply pass it to Apache?

This method would allow you to use htaccess files as needed for dynamic content, and would allow you to have the benefits of speed on both the static and dynamic sides.

This would also allow you to use standard WordPress configurations if you’re using WordPress, and allow you to more easily transfer your sites from an existing Apache server to an Nginx-Apache combination setup.

This is the setup I discovered and that allows me to load my client’s sites, as well as my own, very quickly. Here’s how I did it…

 

Automatic Installation?

If you like the result of the tutorial, but run into problems or would just like to have the work done automatically, we can help you with that. We have an automated script that can SSH into your server and run this tutorial from beginning to end (as long as it’s running CentOS 7). If you would like this done for you ($100), please contact us using the form below.

 

Get Started





 


Part 1: Introduction and Planning

Why it’s important to have your pages load in under 2 seconds, and a plan of how we will set up and configure the server.

Initial setup of the server, including installing CentOS7, installing tools, installing SSH and SSL, enabling repositories, and installing support packages.

Part 3: MySQL, Apache, PHP7, & Composer

Installation of MySQL database serverApache web serverPHP, and Composer package manager for PHP

Part 4: PHPMyAdmin & Redis

How to download, install, and configure PHPMyAdmin; How to install and configure Redis

Part 5: SSL Certificate & Apache Configuration

How to create a self-signed SSL certificate; how to configure Apache as a PHP backend

Part 6: FTP & DNS

How to install and configure an FTP server with dynamic users; how to set up a DNS server

Part 7: Installing Nginx

How to download, build, and install Nginx with additional modules

Part 8: Configuring Nginx

How to set up Nginx configuration files including (with explanations): nginx.confGzip compression settingsvisitor browser caching settingsSSL settingsreverse proxy settings for sending data to the Apache serverreverse proxy connection configurationsfile access restrictions, and WordPress configuration settings

Part 9: Adding a WordPress Website

How to add a WordPress website to the server including configuring the DNS Server, adding a verified SSL certificate, either manually or for free using Let’s Encrypt, setting up FTP for your site, configuring Apache, configuring Nginx, uploading your WordPress site files, and importing your MySQL database.

Part 10: WordPress Website Speed Improvements

Speeding up your WordPress installation using a Redis plugin and a caching plugin.



Tags:

Comments are closed here.

Scroll To Top