Chapter 6. Application Integration

To provide examples of serving real-world applications with NGINX Unit, this chapter will demonstrate step-by-step setups of some common application frameworks. In this chapter, you will learn how to serve WordPress, a common PHP content management system. You will also learn how to serve applications based in common frameworks such as Django, Flask (Python frameworks), and Express (a Node.js framework). A Ruby example is also provided, making use of the common framework Ruby on Rails. This chapter will demonstrate how to install applications onto a system and ensure that they have the correct file permissions and the configuration of NGINX Unit needed to serve them.

6.1 WordPress

Problem

You need to run WordPress with NGINX Unit.

Solution

To install WordPress, if you haven’t already done so, check the prerequisites to ensure that you have the necessary requirements. Next, configure the WordPress database. Then download and extract the WordPress files:

sudo mkdir /var/app/
sudo cd /var/app/
sudo wget https://wordpress.org/latest.tar.gz
sudo tar xzvf latest.tar.gz

In this example, the WordPress files will be stored in /var/app/wordpress/.

Update the wp-config.php file with your database settings and other customizations.

Set the user file permissions for WordPress to ensure that the user that owns the PHP processes and the user running the Unit server are able to access the files:

 sudo chown -R wpuser:www-data /var/app/wordpress/ sudo find ...

Get NGINX Unit Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.