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
Note
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 http://nginx.org/en/download.html. 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 [nginx] name=nginx repo baseurl=http://nginx.org/packages/centos/7/$basearch/ gpgcheck=0 enabled=1
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:
- Install the NGINX signing key by downloading it from http://nginx.org/keys/nginx_signing.key and adding it to the apt keyring:
sudo apt-key add nginx_signing.key
- Append the nginx.org repository to the end of
/etc/apt/sources.list
:vi /etc/apt/sources.list deb http://nginx.org/packages/debian/ jessie nginx deb-src http://nginx.org/packages/debian/ jessie nginx
- 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 nginx.org 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.