LEMP Configuration for High Traffic WordPress on Small VPS (512 RAM)

(Last Updated On: 15 Mar 2017)

With the VPS expansion you can now get a (very) small virtual private server (VPS) for a very affordable price. However, when you get a server with something like 256MB or 512MB RAM and a portion of CPU power, using default LEMP settings is a pretty bad idea.

Performance and scalability tuning of a server is more of an art than science, in the sense that there’re no ready-to-use formulas. Optimal server settings depend on many unique factors: web-app code, traffic to the site, site’s information architecture among other things. It’s virtually impossible to really optimize server settings without thorough understanding of the web application and a lot of testing.

 

Prerequisites

Before you begin this guide, there are some important steps that you need to complete on your server.

You’ll need to have a LEMP (Linux, Nginx, MariaDB, and PHP) stack installed on your VPS instance. If you don’t have these components already installed and configured, you can use this guide to learn how to install LEMP.

When you are finished with these steps, you can continue with this guide.

Following are some variables for various settings files that have been modified from their default values.

 

Tuning PHP

Edit the file /etc/php.ini and change the this

 

Object Cache

An object cache stores potentially computationally expensive data such as database query results and serves them from memory. This greatly improves the performance of WordPress as there is no longer a need to query the database on every page load for information already stored within the object cache.

Redis is the latest and greatest when it comes to object caching. However, popular alternatives include Memcache and Memcached.

To install Redis, issue the following commands.

It’s also a good idea to set a maximum memory usage. As I’m only using a 512Mb server, I set mine to 64mb.

Uncomment the line # maxmemory and set the desired value.

Save the configuration and restart both Redis and PHP-FPM.

Enable Redis service to start on boot:

verify that redis is running and working as expected

OR

 

Tuning PHP-FM

Edit file /etc/php-fpm.d/www.conf and change the this

Save the configuration and restart PHP-FPM.

 

 

to be continues … 

 

zzzzzzzzzzzzzzzzzz