Chapter 2. Installation

The first step for using NGINX Unit is installing it. NGINX Unit can be installed on a wide variety of systems. This chapter will detail how to install Unit on the major Linux distributions such as Debian, Ubuntu, Red Hat, CentOS, and Amazon Linux through NGINX package repositories. Other installation methods, such as compiling from source and using third-party repositories, are also included to enable success with NGINX Unit on virtually any Linux-based platform.

2.1 Red Hat–Based Systems (.rpm)

Problem

You need to install NGINX Unit on Red Hat, CentOS, or Amazon Linux.

Solution

Create a file named /etc/yum.repos.d/unit.repo that contains the following contents:

[unit]
name=unit repo
baseurl=https://packages.nginx.org/unit/OS/$releasever/$basearch/
gpgcheck=0
enabled=1

Alter the file, replacing OS at the end of the URL with rhel, centos, amzn, or amzn2, depending on your distribution.

Install the Unit base package:

sudo yum install unit

Install additional modules that you may want to use with Unit:

RHEL-like systems version 6.x:

sudo yum install unit-devel unit-jsc8 unit-php unit-python

For RHEL-like systems version 7.x and 8.x, you must specify versions of some language modules:

sudo yum install unit-devel unit-jsc8 unit-jsc11 \
      unit-perl unit-php unit-python27 unit-python36

Discussion

The file you just created for this solution instructs the yum package management system to utilize the Official NGINX Unit package repository. The command ...

Get NGINX Unit Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.