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 stopNext, update apt-get:
sudo apt-get updateAnd finally, install NGINX:
sudo apt-get install nginxNGINX 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 nginxOther basic NGINX commands:
Stop:
sudo systemctl stop nginxStart:
sudo systemctl start nginxRestart:
sudo systemctl restart nginxReload configurations:
sudo systemctl reload nginxInstall NGINX on CentOS 7
If Apache is installed and running, you will need to stop the Apache process before installing NGINX:
sudo apachectl stopNext, install the EPEL repository:
sudo yum install epel-releaseAnd finally, install NGINX:
sudo yum install nginxOnce the installation is complete, start NGINX with the command:
sudo systemctl start nginxThen configure NGINX to automatically start if the server is rebooted with the command:
sudo systemctl enable nginxIf 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 nginxOther basic NGINX commands:
Stop:
sudo service nginx stopStart:
sudo service nginx startRestart:
sudo service nginx restartReload configurations:
sudo service nginx reload