Give us a call: (800) 252-6164
How to make your website load in under 2 seconds using Apache, Nginx, Redis, PHP7, MySQL, and WordPress

Load Times Under 2s: Installing Nginx

May 6, 2018 | By admin | Filed in: hosting.

Next up we need to compile and install nginx. We can’t simply run the yum command because we’re going to need to add some modules to the Nginx program. This will help speed things up when serving web pages to visitors.

First we need to install the pcre library. We are going to have to download, compile, and install it ourselves. The pcre library is used by the engine X core and the rewrite modules to provide support for regular expressions. You’re going to want to download the most recent version. As of writing this that’s version 8.41.

 

Then extract it, configure it, make it, and install it.

 

Next up or going to need the zlib library. This is required by inch next for the GSAT module and provides compression functionality. You’re going to want to download the most recent version, as of writing this that is version 1.2.11.

 

Then extract it, configure it, make it, and install it.

 

Now we need the openssl libraries. This will provide SSL encryption to our nginx server. Again download the most recent openssl version, as of writing this that’s version 1.1.1.

 

Then extract it, configure it, make it, and install it.

 

With all of those libraries belt we can finally download and configure nginx with our modules. Replace the “nginx-*” with the folder name in your downloaded source.

 

You can feel free to add or remove modules as needed. A full list of the available modules can be found here: https://docs.nginx.com/nginx/admin-guide/installing-nginx/installing-nginx-open-source/ .

If everything configured properly, you can make, and install Nginx.

 

We need to also create a user for the Nginx process.

 

… and a cache folder

At this point and Nginx should be fully compiled and installed. Now we’re going to test it. We’re going to run it, check if the processes running, and then and the process if it is working. So first start the process:

 

Next, find the process id of the Nginx server.

 

And if it shows up and is working, end the process.

 

Now we need to create a service daemon for the process so we can start, stop, and enable Nginx on-startup. When you install a program from scratch, this isn’t created automatically, so we need to make it ourselves. Create the nginx.service file

 

… and copy and paste the following code into it

 

Now, reload the daemons

 

Next we need to create the initialization script for Nginx. Open the file

 

… and copy in the script

 

Now, make the script executable

 

Enable the Nginx process

 

Check that it’s enabled properly

 

Restart the process

 

And check that it’s working.

 

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.

    Part 2: Installing Software

    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