O'Reilly logo

NGINX Unit Cookbook by Derek DeJonghe

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 6. Application Integration

Introduction

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 (a Python framework) and Express (a Node.js framework). 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.

WordPress

Problem

You need to run WordPress with NGINX Unit.

Solution

To install WordPress, if you haven’t already done so, check 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 NGINX web server is able to access the files:

sudo chown -R wpuser:www-data /var/app/wordpress/
sudo find /var/app/wordpress/ -type d -exec chmod g+s {} \; sudo chmod g+w /var/app/wordpress/wp-content ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required