Knowledge Base

How to install the Nginx web server

This article describes how to install Nginx, a popular web server noted for its high performance. Nginx was originally designed as an alternative to the Apache web server, with an emphasis on speed.

The information in this article only applies to the products listed in the Article Details sidebar. You must have root access to the server to follow the procedures described below.

Installing Nginx

To install Nginx, follow the appropriate procedure below for the Linux distribution installed on your server. If your server does not use any of the following Linux distributions, see the documentation for your distribution for information about how to install Nginx.

Debian and Ubuntu

To install Nginx on Debian and Ubuntu, follow these steps:

  1. Log in to the server using SSH.
  2. As the root user, type the following commands:
    apt update
    apt install nginx
    
  3. Use your web browser to visit the IP address (or domain name, if you have one configured) of your server. You should see the default Welcome to nginx! page.
CentOS and Fedora

To install Nginx on CentOS and Fedora, follow these steps:

  1. Log in to the server using SSH.
  2. As the root user, type the following commands:
    yum -y update
    yum -y install epel-release
    yum -y install nginx
    systemctl enable nginx
    
  3. Use your web browser to visit the IP address (or domain name, if you have one configured) of your server. You should see the default Welcome to CentOS page.

Publishing web content

The default document root directory location varies depending on the Linux distribution you are using:

  • For Debian and Ubuntu, the document root directory is /var/www/html.
  • For CentOS and Fedora, the document root directory is /usr/share/nginx/html.

To publish content, place your files in the document root directory so site visitors can access them.

More Information

To view the official online documentation for Nginx, please visit http://nginx.org/en/docs.