What is a web server?
NicolasBrondinBernard
No, PHP is not a web server, and neither is NodeJS! To understand this properly, let's talk about an ultra-simplified web server.

Article published on 10/08/2020, last updated on 09/08/2026
When you hear the word "server," it's sometimes hard to understand exactly what's being talked about as a beginner, because yes, a server can refer to both a machine and a piece of software, which causes some confusion when you're starting out.
First thing: When we talk about a web server, we're talking about the software part, the program, and not the machine!
A simple web server
I'm not going to explain in depth how the web works, but to understand the role of a web server, you need to know its two primary technologies:
The HTTP protocol (HyperText Transfer Protocol) and the HTML language (HyperText Markup Language).
The web was built on these two technologies, in addition to the Internet network, which I won't go into here.
If you're interested in the history of the Internet, I invite you to read my article on the subject!
The primitive web works like this: A visitor requests a resource by sending an HTTP request (e.g., GET https://example.com) and receives the requested resource in return in the form of an HTML document.
Ultimately, we call a web server any software capable of receiving and interpreting an HTTP request in order to return a response containing an HTML document.
Even though today a web server is also capable of returning other files such as images, videos, audio, or even raw data, these are additional features without which we would still call it a web server.
Be careful not to confuse the function of the web server with server-side scripts, written for example in PHP!
PHP is used to script the server's behavior so that the returned data is dynamic, but the software part that handles incoming requests remains the web server (Apache, for example), which forwards them to PHP, which will take care of executing the desired scripts.
Which language should be used to develop a web server?
It is of course possible to write a web server with most programming languages, the only constraint being the ability to open a TCP/IP connection (on which the HTTP protocol is based) and listen on it.
It's even possible to write a web server entirely in PHP, for instance, as explained in this article: http://station.clancats.com/writing-a-webserver-in-pure-php/
Low-level languages are generally favored for their performance, which is why Apache and Nginx are written in C, but there are also servers written in Java (like Tomcat) or even in JavaScript thanks to NodeJS.
Note that ExpressJS is not a web server but a web application "framework" based on the "http" module provided by NodeJS, thanks to which it is possible to set up a basic web server in just a few lines of code like this:
const http = require('http');
let server = http.createServer(function(request, response){
response.writeHead(200, {'Content-Type': 'text/html'});
response.end('');
});
server.listen(80);
So you'll understand that it's possible to set up a web server with any language!
Note that even today, more than 80% of the sites available on the web are hosted on Apache or Nginx servers, while NodeJS accounts for only 0.1% of websites.
Bonus!
"Does a web server necessarily have to be connected to the Internet?"
No, in fact talking about a "web server" is a distortion, we should really be talking about HTTP servers, and that's actually Apache's official name: "The Apache HTTP Server Project".
"Is a server that returns all sorts of files in response to an HTTP request necessarily a web server?"
No, it could simply be a file server (like Samba for example); a web server is expected to return files with the correct headers and MIME types that will allow the web browser (or client) to interpret them correctly (for display, or download, for example).
"Why do we call it a server?"
The term comes from the English verb "to serve" (and not "server" like a "waiter" — well, actually a waiter is called a server!). There seems to be a correlation between the fact that we send requests (like tickets) and have to wait for the responses to our requests one after another (not necessarily in the right order, by the way).
No spam. Only free content, news, and ever more resources to level up your skills!
Join +1500 developers
No comments yet