NGINX is one of the most popular open-source server software. We can use it for load balancer, mail proxy, and HTTP cache, hide port, redirect request etc.
NGINX is mainly used for it's spectacular architecture, speed and scalability.
The goal behind the creation of NGINX was to create the quickest web server.
How does NGINX work?
When a user makes a request to access a web page, the browser transmits the server of that website. Next,the server finds the requested files for the page and gives it to the browser.
Nginx uses an asynchronous, event-driven procedure where requests are managed in a single thread so it will use very low memory and huge concurrency.
Nginx has one master process and manages various worker processes. The master manages the worker processes, while the workers do the real processing. Because Nginx is asynchronous, each request can be executed by the worker concurrently without preventing extra requests.
Functional web servers generate a separate thread for each request, but NGINX does not work that direction. Worker connections sent the requests to a worker process, which will also give that to the master process. Finally, the master process renders the result of those requests.
What Can NGINX Do for You?
NGINX is a multi function tool so we can easily do load balancer, reverse proxy, content cache, etc.NGINX is less expensive and more configurable than hardware and is aimed at high-level cloud architectures.
More than 400 million websites are using NGINX to reach their content very fast and securely. NGINX continues adding features.
How to Set Up NGINX as a Web Server?
To install NGINX follow these steps:
1. Enter your terminal.
2. Download the NGINX signing key:
3. Add the key:
4. Change directory to /etc/apt.
Update the NGINX software
6. Install NGINX:
7. Type Y when prompted.
8. Start NGINX:
Now that we’ve risen the NGINX software, we’ll see at the web page that NGINX serves by default. Begin a new tab in the browser and paste the IP address of your server into the address bar. If you see below window means NGINX is installed and running successfully:
After the above, we will set up some files for your site server configuration.
Create a folder with example.com and go to that folder.
inside the above folder create a file called main.html and a folder called firstapp.
In the firstapp folder, create a file called firstapp.html with some HTML tags and text.
Go to your Nginx config file and rename the default Nginx config file to some other name for preventing using it as the default conf. File
Create your own config file with .conf extension and paste this configuration in that file.
6. Reload NGINX
7. Open your web page at this URL
So that’s it! You now have a working Ubuntu instance working NGINX.
You can easily make a website on any domain with subdomain you would like to use.
First, you need the website files. You can put them somewhere inside /var/www.
we will use /var/www/main.test.com
You also need to set up your DNS records properly, so your subdomain redirects to your instance.
Now you can configure Nginx to run for a specific website on a specific domain. Make a new configuration in Nginx.
Inside the configuration put and edit the following:
Inside this configuration modify the following to your correct settings
root (your website file folder)
server_name (your website domain)<^>
Now you need to enable the configuration, make a symlink to the enabled sites:
Last thing is restart Nginx:
You should now be able to check the website on your sub domain.
In this post, we learned what NGINX is, how it works, how to install NGINX and configure your server with application services over the Internet.
Need a consultation?
Drop us a line! We are here to answer your questions 24/7
Areas we serve
4100 NW Loop 410, Suite 200, San Antonio, Texas, USA 78229
7 Artisan Place Harrow, HA3 5DS
4th Floor, Timber Point, Prahaladnagar Road, Ahmedabad, Gujarat - 380015