Chapter 2. Installation

Introduction

The first step toward 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, and CentOS 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.

Red Hat–Based Systems (.rpm)

Problem

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

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 or centos, depending on your distribution.

Install the Unit base package:

sudo yum install unit

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

sudo yum install unit-php unit-python unit-go unit-perl \
      unit-devel unit-jsc-common unit-jsc8 unit-jsc11

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 that follows installs Unit from the Official repository, as well as the Unit modules needed for each application language you may want to run.

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.