How to Install NGINX

Leave your reply

Introduction

NGINX (pronounced "Engine X") is a free, open-source web server and reverse proxy which is tuned for high performance and stability and designed to be easy to use. NGINX uses a scalable, event-driven architecture, which makes it much less resource-intensive than web servers like Apache. NGINX is used by some sites with the highest traffic on the internet, but also scales down well to the smallest servers.

Requirements

  • A server running Linux (Ubuntu 16.04 or CentOS 7)

Install NGINX on Ubuntu 16.04

If Apache is installed and running, you will need to stop the Apache process before installing NGINX:

sudo apachectl stop

Next, update apt-get:

sudo apt-get update

And finally, install NGINX:

sudo apt-get install nginx

NGINX will automatically begin running and will be configured to start automatically when the server is rebooted.

Do not be alarmed if you visit your website and see an "**Apache2 Ubuntu Default Page***". This is a static HTML page, which is created by default when Apache is installed. If NGINX is running, this index.html page will automatically be served as the home page if it has not been replaced.

You can check the status of NGINX by using the command:

systemctl status nginx

Other basic NGINX commands:

Stop:

sudo systemctl stop nginx

Start:

sudo systemctl start nginx

Restart:

sudo systemctl restart nginx

Reload configurations:

sudo systemctl reload nginx

Install NGINX on CentOS 7

If Apache is installed and running, you will need to stop the Apache process before installing NGINX:

sudo apachectl stop

Next, install the EPEL repository:

sudo yum install epel-release

And finally, install NGINX:

sudo yum install nginx

Once the installation is complete, start NGINX with the command:

sudo systemctl start nginx

Then configure NGINX to automatically start if the server is rebooted with the command:

sudo systemctl enable nginx

If you visit your URL or IP address in a browser, you should see the NGINX greeting page.

You can check the status of NGINX by using the command:

systemctl status nginx

Other basic NGINX commands:

Stop:

sudo service nginx stop

Start:

sudo service nginx start

Restart:

sudo service nginx restart

Reload configurations:

sudo service nginx reload