Skip to main content

What a web server is and why a site needs one

Hosting & cPanel · 13.10.2026 · 5 min read
Illustration for “What a web server is and why a site needs one”

When a browser opens a site, the request first lands not on the site itself but on a web server — a program that accepts incoming connections, decides what to do with them, and returns a ready response. This article explains what a web server is, how popular implementations differ, and how it connects to the rest of a site's stack. Understanding this role helps find the cause of problems faster when a site returns an error or takes a long time to load.

What happens when you open a site

Within a fraction of a second between typing an address and seeing a page, several steps take place.

  • The browser finds the server's IP address from the domain name via DNS.
  • The browser opens a TCP connection with the server on port 80 or 443.
  • The web server accepts the request and decides which file to return or which handler to call.
  • The server builds a response and sends it back to the browser, which renders the page.

A web server as a program: what it does

A web server is a program that listens on a network port, accepts HTTP requests, and returns content according to set rules: a static file, the output of another program, or an error if the requested resource does not exist. Besides serving files, a web server usually handles response compression, caching of static content, rate limiting, and routing requests to the right handler. These functions can be turned on and tuned separately, without changing the site's own code.

The state of an installed web server and the correctness of its configuration can be checked with standard commands.

systemctl status nginx
nginx -t

Different web servers handle concurrent connections differently: some use one thread per connection, others use an event-driven model with a small number of worker processes. The setup and basic configuration order for one of the most widely used web servers is described in the article configuring nginx. The choice of a specific implementation rarely matters much for a small site, but it becomes important as load grows.

A web server and the rest of the stack: where it sends requests

A web server rarely works alone. It usually serves requests for static files itself, while requests that require running the site's code are passed further on — to a PHP interpreter, an application server, or a database, and their response is then returned to the browser. How to assemble a typical stack from a web server, a PHP handler, and a database on one server is described in the article installing LEMP.

Comparing connection-handling approaches

ApproachHow connections are handledStrong point
Process per connectionA separate process or thread per connectionA simple request-handling model
Event-driven modelA small number of processes serve many connectionsMemory savings under high load
Reverse proxyThe server passes the request to another handlerSeparation of static and dynamic content
Built-in cachingRepeated requests are served from cache without hitting the backendReduced load on the application

In practice a web server usually combines several approaches at once: it caches static content, acts as a reverse proxy at the same time, and handles connections using an event-driven model.

What to do: how to choose and configure a web server

  1. Determine the load type: mostly static, mostly dynamic requests, or a mixed profile.
  2. Choose a web server with a connection-handling model suited to that load.
  3. Set up routing of dynamic requests to the application handler and caching of static content.
  4. Check the configuration for syntax errors before applying it on a production server.
  5. If the current web server cannot handle the load, consider moving to another one — the migration order is described in the article migrating from Apache to nginx.

This order works both for a brand-new project and for a site that is already running and has started responding noticeably slower under load.

Frequently asked questions

How does a web server differ from hosting?

Hosting is the place and the hardware where a site is located, while a web server is the program on that hardware that directly accepts browser requests and returns responses.

Can several web servers be used for one site?

Yes, it is common for one web server to act as a reverse proxy in front of another: for example, accepting all external connections and distributing them among internal application servers.

Does a static site without dynamic content need a web server?

Yes, even a site made of plain HTML files needs a program that listens on a port and returns those files to the browser on request — that is exactly what a web server is.

Was this article helpful?
← Back to Knowledge Base Ask Support