Installing NGINX using a package manager

Chances are that your operating system of choice already provides nginx as a package. Installing it is as simple as using your package manager’s commands:

  • Linux (deb-based)

    sudo apt-get install nginx
  • Linux (rpm-based)

    sudo yum install nginx
  • FreeBSD

    sudo pkg_install -r nginx


The sudo command is representative of what you need to execute on your operating system to achieve superuser (root) privileges. If your operating system supports role-based access control (RBAC), then you would use a different command, such as pfexec, to achieve the same goal.

These commands will install NGINX into standard locations, specific to your operating system. This is the preferred installation method if you need to use your operating system’s packages.

The NGINX core team also provides binaries of the stable version, available from Users of distributions without an nginx package (such as CentOS) can use the following instructions to install pre-tested and pre-compiled binaries.

Installing NGINX on CentOS

Add the NGINX repository to your yum configuration by creating the following file:

sudo vi /etc/yum.repos.d/nginx.repo
name=nginx repo

Then install nginx by executing the following command:

sudo yum install nginx

Alternative instructions for installing an nginx-release package are available at the preceding URL.

Installing NGINX on Debian

Let’s install NGINX on Debian using the following steps:

  1. Install the NGINX signing key by downloading it from and adding it to the apt keyring:
    sudo apt-key add nginx_signing.key
  2. Append the repository to the end of /etc/apt/sources.list:
    vi /etc/apt/sources.list
    deb jessie nginx
    deb-src jessie nginx
  3. Then install nginx by executing the following command:
    sudo apt-get update
    sudo apt-get install nginx

If your operating system does not include nginx in its list of available packages, the version is too old for what you would like to do, the packages at don’t serve your needs, you would like to use the development release of NGINX, or if you want to enable/disable specific modules, then compiling NGINX from source is the only other option.

Related Articles

How to add swap space on Ubuntu 21.04 Operating System

How to add swap space on Ubuntu 21.04 Operating System

The swap space is a unique space on the disk that is used by the system when Physical RAM is full. When a Linux machine runout the RAM it use swap space to move inactive pages from RAM. Swap space can be created into Linux system in two ways, one we can create a...

read more

Lorem ipsum dolor sit amet consectetur


Submit a Comment

Your email address will not be published. Required fields are marked *

eleven − seven =