How To Install Nginx on Ubuntu

NGINX is open-source software for web serving, reverse proxying, caching, load balancing, media streaming, and more. It started out as a web server designed for maximum performance and stability.

Today, there are even more connections that web servers have to handle. For that reason, NGINX offers an event-driven and asynchronous architecture. This feature makes NGINX one of the most reliable servers for speed and scalability.

Due to its superb ability to handle a lot of connections and speed, many high-traffic websites have been using NGINX’s service. Some of these online giants are Google, Netflix, Adobe, Cloudflare, WordPress.com, and many more.

NGINX vs Apache

Among popular web servers, Apache is one of the main rivals for NGINX. It has been around since the 90s and has a large user community as well. If you are curious about which web server is best for your needs, take a look at this brief and informative comparison between NGINX and Apache.

OS support

Compatibility is one of the little details you should consider when choosing software. Both NGINX and Apache can run on many operating systems that support the Unix system. Unfortunately, NGINX’s performance on Windows is not as great as on other platforms.

User support

Users, from first-timers to professionals, always need a good community that can help when they face problems. While both NGINX and Apache have mailing support and a Stack Overflow forum, Apache lacks support from its company, the Apache Foundation.

Performance

NGINX can simultaneously run 1000 connections of static content two times faster than Apache and uses a little less memory. When compared for their performance on running dynamic content, however, both have the same speed. NGINX is a better choice for those who have a more static website.

First, we should update our local package index before we begin so that we are using the most up-to-date information. Afterward, we will install Nginx:

sudo apt-get update sudo apt-get install nginx

By default, Nginx automatically starts when it is installed.

Check your Nginx Web Server running or not

You can access the default Nginx landing page to confirm that the software is running properly by visiting your server's domain name or public IP address in your web browser.

Try typing this at your server’s command prompt:

curl http://localhost

or you can put the IP address of the server machine on the browser.

http://server_domain_or_IP


Install Nginx on Ubuntu

To stop your web server, you can type:

sudo service nginx stop

To start the webserver when it is stopped, type:

sudo service nginx start

To stop and then start the service again, type:

sudo service nginx restart

We can make sure that our web server will restart automatically when the server is rebooted by typing:

sudo update-rc.d nginx defaults

This should already be enabled by default, so you may see a message like this:

Once you’ve installed Nginx, here are the locations of important files:

nginx is installed in folder: /etc/nginx

nginx config file: /etc/nginx/nginx.conf

The default site is served from: /usr/share/nginx/html

Default site config info: /etc/nginx/sites-available/default


In this post, We have seen How To Install Nginx on Ubuntu.