Nginx is a web server that can also be used as a reverse proxy, load balancer, mail proxy, and HTTP cache. It was created in 2004 by Igor Sysoev.
Another very popular web server is Apache which existed before Nginx. However, most people prefer to use Nginx for their applications for a number of reasons:
- Faster Static Resources: Nginx serves static resources without the need for a server-side language
- It performs 2.5 times faster than Apache
- Higher Concurrency: it can potentially receive thousands of requests on a single process thread and respond to them as fast as possible
Installing Nginx with Package Managers
Ubuntu - is a Linux distribution that uses the APT package manager. To install Nginx on Ubuntu, follow these steps:
- Update the package lists: apt-get update
- Run the install command: apt-get install nginx
- Check your web server: at the end of the installation process Ubuntu starts Nginx. Run systemctl status nginx to check if Nginx is up and running
- Check your server's IP address in the browser, you should see the default Nginx landing page
CentOS - CentOS ships with the YUM package manager.
- Add the EPEL software repository: YUM does not come with an Nginx package and for this reason, you need to provide YUM with a package source containing Nginx. Run the yum install epel-release command
- Install Nginx with the following yum command: yum install nginx
- Start the Nginx service: Nginx will not automatically start after installation. Use the systemctl start nginx command to start the service. After that, check the status with systemctl status nginx
Enter your server's IP address on the browser to check that everything worked fine. You should see the default CentOS Nginx web page