Web server


In this article, we explain what website servers are, how website servers work, và why they are important.

Bạn đang xem: Web server

Prerequisites: Objective:
You should already know how the mạng internet works, & understand the difference between a website page, a web site, a webserver, và a search engine.
You will learn what a web server is và gain a general understanding of how it works.

The term web server can refer to lớn hardware or software, or both of them working together.

On the hardware side, a web server is a computer that stores web server software & a website"s component files. (for example, HTML documents, images, CSS stylesheets, and JavaScript files) A web hệ thống connects lớn the Internet và supports physical data interchange with other devices connected to the web.

At the most basic level, whenever a browser needs a tệp tin that is hosted on a web server, the browser requests the file via HTTP. When the request reaches the correct (hardware) website server, the (software) HTTP server accepts the request, finds the requested document, & sends it back khổng lồ the browser, also through HTTP. (If the vps doesn"t find the requested document, it returns a 404 response instead.)


To publish a website, you need either a static or a dynamic website server.

A static website server, or stack, consists of a computer (hardware) with an HTTP server (software). We hotline it "static" because the vps sends its hosted files as-is khổng lồ your browser.

A dynamic web server consists of a static web server plus extra software, most commonly an application server & a database. We call it "dynamic" because the application vps updates the hosted files before sending content to your browser via the HTTP server.

For example, to lớn produce the final webpages you see in the browser, the application vps might fill an HTML template with content from a database. Sites like MDN or Wikipedia have thousands of webpages. Typically, these kinds of sites are composed of only a few HTML templates & a giant database, rather than thousands of static HTML documents. This thiết lập makes it easier to maintain & deliver the content.

Deeper dive

To review: lớn fetch a webpage, your browser sends a request lớn the website server, which searches for the requested file in its own storage space. Upon finding the file, the vps reads it, processes it as-needed, và sends it khổng lồ the browser. Let"s look at those steps in more detail.

Hosting files

First, a web hệ thống has khổng lồ store the website"s files, namely all HTML documents và their related assets, including images, CSS stylesheets, JavaScript files, fonts, và video.

Technically, you could host all those files on your own computer, but it"s far more convenient lớn store files all on a dedicated web vps because:

A dedicated web hệ thống is typically more available. (up and running) Excluding downtime và systems troubles, a dedicated web hệ thống is always connected khổng lồ the Internet. A dedicated web vps is typically maintained by a third-party.

For all these reasons, finding a good hosting provider is a key part of building your website. Examine the various services companies offer. Choose one that fits your needs và budget. (Services range from free to thousands of dollars per month.) You can find more details in this article.

Xem thêm: Hệ Điều Hành Linux - Ưu, Nhược Điểm Của

Once you have web hosting service, you must upload your files to your website server.

Communicating through HTTP

Second, a web server provides support for HTTP (Hypertext Transfer Protocol). As its name implies, HTTP specifies how lớn transfer hypertext (linked website documents) between two computers.

A Protocol is a phối of rules for communication between two computers. HTTP is a textual, stateless protocol.


All commands are plain-text và human-readable.


Neither the server nor the client remember previous communications. For example, relying on HTTP alone, a server can"t remember a password you typed or remember your progress on an incomplete transaction. You need an application hệ thống for tasks lượt thích that. (We"ll cover that sort of công nghệ in other articles.)

HTTP provides clear rules for how a client and server communicate. We"ll cover HTTP itself in a technical article later. For now, just be aware of these things:

Usually only clients make HTTP requests, và only to servers. Servers respond khổng lồ a client"s HTTP request. A hệ thống can also populate data into a client cache, in advance of it being requested, through a mechanism called a server push. The web server must answer every HTTP request, at least with an error message.

On a web server, the HTTP server is responsible for processing & answering incoming requests.

Upon receiving a request, an HTTP hệ thống first checks if the requested URL matches an existing file. If so, the web vps sends the file content back lớn the browser. If not, an application server builds the necessary file.

Static vs. Dynamic content

Roughly speaking, a server can serve either static or dynamic content. Remember that the term static means "served as-is". Static websites are the easiest to lớn set up, so we suggest you make your first site a static site.

The term dynamic means that the server processes the content or even generates it on the fly from a database. This approach provides more flexibility, but the technical stack is more complex, making it dramatically more challenging to build a website.

There are so many application server technologies that it"s difficult lớn suggest a particular one. Some application servers cater khổng lồ specific website categories lượt thích blogs, wikis, or eCommerce; others are more generic. If you"re building a dynamic website, take the time lớn choose giải pháp công nghệ that fits your needs. Unless you want khổng lồ learn web hệ thống programming (which is an exciting area in itself!), you don"t need to lớn create your own application server. That"s just reinventing the wheel.

Next steps

Now that you are familiar with web servers, you could:

Found a problem with this page?

Last modified: Feb 1, 2022, by MDN contributors

Change your languageSelect your preferred language English (US)EspañolFrançais日本語한국어Português (doBrasil)Русский中文 (简体)正體中文 (繁體) Change language