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.
You need to install NGINX Unit on Red Hat or CentOS.
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
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.
System Requirements
CentOS Package Documentation
RHEL Package Documentation
You need to install NGINX Unit on a Debian or Ubuntu machine.
Ensure that the Advanced Package Tool (APT) system is able to use HTTPS repositories:
sudo apt-get install apt-transport-https
Create a file named /etc/apt/sources.list.d/unit.list that contains the following contents:
deb https://packages.nginx.org/unit/OS/ CODENAME unit deb-src https://packages.nginx.org/unit/OS/ CODENAME unit
Alter the file, replacing OS
at the end of the URL with ubuntu
or debian
, depending on your distribution. Replace CODENAME
with the code name of your system. If you don’t know the code name the following command will output the value you need:
lsb_release -c
Codename: xenial # Example
Run the following commands to install the NGINX signing key and install Unit:
wget http://nginx.org/keys/nginx_signing.key sudo apt-key add nginx_signing.key sudo apt-get update sudo apt-get install unit
A version of the language needs to be specified for certain Unit modules. At the time of this writing, not all versions of all languages are supported across all versions of the OS. You can search for module packages available from the repository for your operating system by using the following command:
apt-cache search unit- |
grep NGINX
Install additional modules that you may want to use with Unit. The following packages are available on all Debian-based systems:
sudo apt-get install unit-php unit-python2.7 unit-perl
unit-ruby unit-dev unit-jsc-common unit-jsc8
The file you just created instructs the apt
package management system to utilize the Official NGINX Unit package repository. The commands that follow download the NGINX GPG package signing key and import it into apt
. Providing the APT system with the signing key enables it to validate packages from the repository. The apt-get update
command instructs the APT system to refresh its package listings from its known repositories. After the package list is refreshed, you can install Unit and any necessary packages from the Official NGINX repository. For Python 3 and Golang, not all minor versions are supported on all systems. The search command demonstrated previously can assist in finding which language versions are available for your system.
System Requirements
Debian Package Documentation
Ubuntu Package Documentation
You want to run NGINX Unit on a system for which NGINX Inc. does not have prebuilt packages, and you do not want to build from source.
Install from a third-party repository. These named repositories are maintained by the community; NGINX has no control or responsibility over these resources.
These third party repositories are maintained by the community. NGINX Inc. is not responsible for them or for what gets installed when using them.
Alpine Linux:
sudo apk update sudo apk upgrade sudo apk add unit sudo apk add unit-openrc unit-perl unit-php7 unit-python3 unit-ruby
Arch Linux:
sudo pacman -S git
git clone
git clone https://aur.archlinux.org/nginx-unit.git
cd
nginx-unit
makepkg -si
FreeBSD:
sudo pkg install -y unit
Gentoo:
sudo emerge --sync sudo emerge www-servers/nginx-unit
Remi’s RPM repository hosts the latest version of PHP for RHEL and its derivatives such as CentOS and Fedora:
sudo yum install --enablerepo=
remi unitphp54-unit-php php55-unit-php php56-unit-php
php70-unit-php php71-unit-php php72-unit-php php73-unit-php
Unit’s Node.js package is called unit-http. It uses Unit’s libunit library; your Node.js applications require the package to run in Unit:
sudo npm install -g --unsafe-perm unit-http
This section has detailed the usage of a number of third-party repositories maintained by the community. It is possible to utilize this information to quickly install prebuilt Unit and Unit module packages on systems that NGINX Inc. does not yet maintain a repository for. Also, the Remi repository contains specific older PHP versions that may be useful to some readers.
System Requirements
Community Repositories Install Documentation
You need to install Unit from source.
You will have to install the packages needed to compile from source. The following includes all the development packages for all supported languages; skip the packages that you are not going to use.
For Debian and Ubuntu:
sudo apt-get install build-essential sudo apt-get install golang sudo curl -sLhttps://deb.nodesource.com/setup_<Node.js version>.x
|
bash -;
apt-get install nodejs sudo apt-get install php-dev libphp-embed sudo apt-get install libperl-dev sudo apt-get install python-dev sudo apt-get install ruby-dev sudo apt-get install libssl-dev
For Amazon Linux, CentOS, RHEL, and Fedora:
sudo yum install gcc make unzip sudo yum install golang sudo curl -sLhttps://rpm.nodesource.com/setup_<Node.js version>.x
|
bash -;
yum install nodejs sudo yum install php-devel php-embedded sudo yum install perl-devel perl-libs sudo yum install python-devel sudo yum install ruby-devel sudo yum install openssl-devel
Clone or download the source code from https://github.com/nginx/unit. If you choose to download, you’ll need to unzip the package that is downloaded. Once the source is cloned or unpacked, move into the base of the project. The next example follows the download path:
curl -O https://codeload.github.com/nginx/unit/zip/master
unzip master
cd
unit-master/
Next, use the configure
script to prepare the source code for installing on your system. Run ./configure --help
to fully understand the flags available. In the following example, the --prefix
option is used to specify the installation directory. Each supported language has an associated module that also needs to be built. Run the configure
script with each application type you need to build a module for:
./configure --prefix=
/opt/unit/
./configure go
./configure perl
./configure php
./configure python
./configure ruby
Next, use the make
command to run the Makefile created by the configure
script and install the software. You will need to run the make
command for each language. Depending on the location and ownership of the --prefix
flag specified by the configure
command, you may need to run the last command with elevated privileges:
make make perl make php make python make ruby sudo make go-install sudo make node-install sudo make install
NGINX Unit is now installed. Validate the installation by getting the help options from the binary:
sudo /opt/unit/sbin/unitd -h
The preceding steps will build and install NGINX Unit from source. A number of configuration flags can be used to modify the build and installation. Unit is ready to use.
3.139.90.131