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.
AlmaLinux and Fedora

To install Nginx on AlmaLinux 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 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 AlmaLinux 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.

Get Nginx hosting

Article Details

  • Product: All unmanaged hosting accounts
  • Level: Intermediate

Other Articles in This Category

Show More

Did you find this article helpful? Then you'll love our support. Experience the A2 Hosting difference today and get a pre-secured, pre-optimized website. Check out our web hosting plans today.

We use cookies to personalize the website for you and to analyze the use of our website. You consent to this by clicking on "I consent" or by continuing your use of this website. Further information about cookies can be found in our Privacy Policy.