Deploy Scalable and Reliable WordPress Site on LEMP(3)

Deploy Scalable and Reliable WordPress Site on LEMP(3)

Introduction In previous post Deploy Scalable and Reliable WordPress Site on LEMP(2), we successful set up Linux+Nginx+PHP+MySQL (LEMP) stack to hold

Deploy Scalable and Reliable WordPress Site on LEMP(2)
Use pfSense to Load Balance Web Servers (1)
Deploy Scalable and Reliable WordPress Site on LEMP(1)

Introduction

In previous post Deploy Scalable and Reliable WordPress Site on LEMP(2), we successful set up Linux+Nginx+PHP+MySQL (LEMP) stack to hold WordPress site. However, Nginx and PHP services were enabled on the same server WEBo1.

In this lab, we will separate PHP to an external server PHP01 and leave WEB01 as Nginx web server only. It adds some flexibility scalability strategy. For performance enhancement details, please refer to Scaling PHP apps via dedicated PHP-FPM nodes, a test post I found online.

Deployment Steps

This lab involves PHP01 deployment and configuration change on WEB01 to forward PHP requests to PHP01. The topology is as below:
nginx_env

Step 1 – Configure PHP01 as php-fpm node

Boot another $5 ubuntu server from DigitalOcean, details available in Deploy Scalable and Reliable WordPress Site on LEMP(1).

Verify PHP01 can access the same WordPress folder we created on FS01 before, by executing the following command on PHP01.

Step 2 – WEB01 forward PHP requests to PHP01

Log onto WEB01, edit the nginx site default file by executing the following command:

Update the file as below; where ‘10.132.19.6’ is PHP01’s private IP, and 9000 is the port used by fastcgi. Comment the local fastcgi socket ‘unix:/run/php/php7.0-fpm.sock’.

Restart Nginx service by executing the following command:

Let’s now log onto the WordPress site, see whether it is still working as expected in Deploy Scalable and Reliable WordPress Site on LEMP(2).

Unfortunately, we get ‘502 Bad Gateway’ message this time.
nginx_badgateway
Fortunately, Nginx provides us error log. Execute the following command on WEB01 to view the log.

Nginx error log reveals the following:

OK…it appears WEB01 passed on the request to PHP01, but PHP01 refused the connection. Step 3 will help resolve the issue.

Step 3 – Allow PHP01 to Listen WEB01

On PHP01, edit PHP ‘www.conf’ file to allow listen on WEB01.

Perform the following changes in ‘www.conf’.

Restart PHP on PHP01 and Nginx on WEB01.

Let’s now access the WordPress site again. ‘Hello world!’ – it’s working!

nginx_resumed.png

The End

COMMENTS

WORDPRESS: 0
DISQUS: 0