Know About Webserver
What is web server?
The server usually completes all the pages from the Internet to your computer browser. So what is this “webserver”? In fact, “server” does not mean a giant computer, not even a single computer. What then? “Server” is basically a software program that works on the HTTP protocol and delivers web pages to the requesting users. It does not require a huge computing system to operate, it can be run on a simple USB drive (pen drive) with XAMPP server software.
Computers used to host websites must have a server program installed. But yes, those who provide you with website hosting services have a lot of dedicated computing systems. Their huge computers have server applications such as Apache, IIS, or NGINX installed. Or you can provide server services using a built-in operating system such as Windows IIS (Internet Information Server), or Ubuntu Linux.
This is about professional servers, but depending on the term, you can also use your computer as a server. If your computer is currently running Windows operating system, you can make your PC a local server or localhost by activating the IIS service from the “Programs and Features” option in the control panel. Once IIS is enabled, you can insert any HTML file into the “wwwroot” directory and run it on the server. Again, if you want, you can run a PHP script by installing a small program called XAMPP on your computer. Many people use this software to run PHP scripts like “WordPress”, “Joomla” etc. on their PC. After setting up your PC as a server, you can view your locally hosted pages using any web browser, and your server can be accessed with any computer or smartphone on the same network connected to your PC.
How does a web server work?
Learn how a web server works. You sit in front of a computer screen, visit the programming hero, and see all the great new tech articles published. Tell your friend about it and send him the link “https://medium.com/ and say, “Look, this is an extreme article.” Your friend entered the link in his browser and went directly to this website. The web browser requested the webserver for the page, and the page moved to the front! But what happened behind it?
When you enter a link in a web browser to visit the site; The browser divides that link into three parts. First, it looks at the protocol (HTTP) then tries to find the server name (https://medium.com) and when it gets the server name it tries to find the requested page (“/ web-server /”). First, the browser name tries to get the IP address of that server from the server, after getting the IP address your web browser tries to establish a relationship with that server machine and connects to port 80. An IP address has many ports and different ports are used for different purposes. For example, suppose you request a page or file to the server via the HTTP protocol, but your browser will connect to port 80. Again, if you want to upload or manage a file in the FTP protocol, it will connect to port 21. So you can think of the port as a lot of doors. For example, we use the front door to get out of the house and use the stairs to get to the roof. Similarly, there are different ports for different tasks.
So once the browser is connected to the IP address and the correct port, it sends a gate request to the server rather than a page. The server accepts the request and finds out on its own system whether the request has a page and whether it is allowed to be given to that user. If all goes well, then the webserver sends the HTML page to the browser. The server sends cookies to the page. The browser reads the HTML tags from the HTML page and renders the page accordingly and displays it on the screen in front of you.
So this is the basic process of working on a server, if you didn’t know it by now, I hope it’s a rough idea now. However, in order to know these issues in more depth, it is necessary to know more details about IP address, port, protocol, name server, domain, etc. Some of these topics I have already discussed in this blog and the rest I will try to discuss later.
Clients and servers:
In general, the number of machines on the Internet can be divided into two parts; Clients and servers. Machines that provide any type of service (such as webserver service or FTP server service) are called servers. And the machines that connect to the server and demand information from there are called clients.
When you connect with Facebook, the Facebook server serves you to check your wall. Your PC receives that page and displays it in front of you. Here your PC is not providing any service but receiving so it is a user machine or client. But when you chat with someone and exchange photos with them, your PC acts as a server once and a client once. Your computer serves as a server when you send a photo to someone and your computer acts as a client when you receive a photo.
A server computer can provide one or more services on the Internet. Maybe a server has special software installed so that it can act as a web server, or it can also act as an email or FTP server. The client receives the service by talking to the server as per his requirement. If your web page is needed, the client talks to the webserver talk to the email server to access the email, and so on.
What is Node JS?
Many of those who are new think Node JS is probably a programming language or framework! But it is completely wrong. Node JS is not a programming language or framework. So what is Node JS?
Node JS is a JavaScript Run-Time Environment. Okay, but what is this Run-Time Environment again?
Take a look at the picture above, see if you understand anything! If you understand anything then you are a Genius! And even if you do not understand, there is no problem! You will understand slowly and I am with you.
Java usually runs through the Java Virtual Machine (JVM). And to execute those Java codes you need Java Runtime Environment,
This means that the Java Runtime Environment knows very well how to run and work properly with the Java code. I don’t want to talk too much about Java because we are now learning Node JS, not Java. I said a little about Java because if you understand this concept of Java, then you can easily understand how Node JS works. I think before learning a thing, you should understand how it works, then you don’t have to go ahead and stop.
How does Node JS work?
We know that JavaScript was created for browsers only. Previously, JavaScript was used only for interactive websites.
Only browsers could understand JavaScript code. But in 2009 a software engineer named Ryan Dahl brought Node JS to market and changed everything!
ADs by Techtunes ADs
With the advent of Node JS, a lot can now be done with JavaScript! Each browser has a JavaScript engine whose job is to convert JavaScript code to machine code.
Google Chrome has the V8 Engine, Mozilla Firefox has the SpiderMonkey, and each browser has its own JavaScript engine. The fastest of all is the V8 Engine and it is open source. Ryan Dahl had a great idea! He built the Node JS in a mixture of C and C + with the V8 engine.
Just like Java Runtime Environment is needed to run Java code, Node JS is needed to run JavaScript code from outside the browser. Now you understand what is Runtime Environment? Well, let’s clear a little more. If we write JavaScript code in Node JS, Node JS converts that JavaScript code to C + code and that C + code is converted to machine code. Eventually, that machine code understands our machine and gives us the output.
This is what happens in the blink of an eye, we don’t understand anything.
And what happens in the case of Java is that Java code runs Java Runtime Environment (JRE) and helps Java Virtual Machine (JVM) understand that code and Java Virtual Machine converts that code to machine code, and machine code can be understood by our machine. !
In the same way, browsers convert JavaScript code to machine code by C + through Javascript Engine. Now you can find the match between Node JS and Java Runtime Environment? Now surely this concept is clear to you?
If not cleared yet, all will be clear as you slowly stay with Node JS!