Showing raw Markdown: the renderer could not load.
## Why this matters Imagine you bake cakes and want customers to find your shop online. Somewhere there must be a computer that holds your pages and hands them to anyone who asks, at any hour. That computer is a **server**. Knowing what a server is, and what happens when you open a web address, takes the mystery out of "the Internet". It also helps you choose how to publish a site and spot the traps, such as thinking a padlock in the address bar means a website is trustworthy. ## Learning objectives - Explain what a server is and how it differs from a personal computer. - Describe what happens between typing a web address and seeing the page (name, request, response). - Compare ways of publishing a website: your own computer, shared hosting, a rented server and the cloud. ## Key concepts ### A server is a role, not a special box Think of a restaurant. Some people **ask** (the customers) and some people **answer** (the kitchen). Nobody is a customer or a cook by birth: it is a role. Computers work the same way. A **client** is a computer, phone or program that asks for something. A **server** is a computer that waits for requests and answers them. The rules of the conversation are called a **protocol**, and both sides must speak the same one. The word "server" describes what a computer does, not what it looks like. Your own laptop becomes a server the moment you run a program on it that answers requests. You will do exactly that in the activities. <figure class="diagram" style="--dg-w: 1040px"><svg xmlns="http://www.w3.org/2000/svg" class="dg" viewBox="0 0 1040 388" width="1040" height="388" role="img" aria-labelledby="webserver-role-title webserver-role-desc" font-family="Inter, system-ui, -apple-system, Segoe UI, Roboto, sans-serif" xml:lang="en"> <title id="webserver-role-title">A server is a role: any computer that answers requests</title> <desc id="webserver-role-desc">On the left, a zone called the client, which asks, holds a laptop or phone with a screen and a keyboard that is switched off or asleep part of the day. On the right, a zone called the server, which answers, holds any computer in the server role: it waits for requests and answers them, and even a laptop can do this for a while. An arrow labelled request, show me the page, points from the client to the server, and an arrow labelled response, the files, comes back. Below, five small cards explain why real servers live in data centres: always on, because they answer at 3 a.m. too; reliable power from backup batteries and generators; cooling, because many machines make a lot of heat; a fast connection with several links to the Internet; and no screen, because they are managed from far away.</desc> <rect class="dg-bg" x="0.5" y="0.5" width="1039" height="387" rx="16" fill="#ffffff" stroke="#e3e3dd"/> <g class="dg-l1"><rect class="dg-tint" x="24" y="24" width="380" height="190" rx="16" fill="#f0f6f9" stroke="#9ac3d9" stroke-width="1.2" stroke-dasharray="6 5"/> <g class="dg-icon" transform="translate(40 37) scale(0.7500)" fill="none" stroke="#0369a1" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M20 16V7a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v9m16 0H4m16 0 1.28 2.55a1 1 0 0 1-.9 1.45H3.62a1 1 0 0 1-.9-1.45L4 16"/></g> <text x="66" y="51" font-size="13" class="dg-ink" fill="#0369a1" font-weight="700">The client: asks</text></g> <g class="dg-l2"><rect class="dg-tint" x="636" y="24" width="380" height="190" rx="16" fill="#f1f7f3" stroke="#a1ccb1" stroke-width="1.2" stroke-dasharray="6 5"/> <g class="dg-icon" transform="translate(652 37) scale(0.7500)" fill="none" stroke="#15803d" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect width="20" height="8" x="2" y="2" rx="2"/><rect width="20" height="8" x="2" y="14" rx="2"/><path d="M6 6h.01"/><path d="M6 18h.01"/></g> <text x="678" y="51" font-size="13" class="dg-ink" fill="#15803d" font-weight="700">The server: answers</text></g> <rect class="dg-card" x="44" y="70" width="340" height="120" rx="12" fill="#ffffff" stroke="#cfcfc8"/> <g class="dg-l1"><g class="dg-icon" transform="translate(60 86) scale(1.2500)" fill="none" stroke="#0369a1" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M20 16V7a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v9m16 0H4m16 0 1.28 2.55a1 1 0 0 1-.9 1.45H3.62a1 1 0 0 1-.9-1.45L4 16"/></g></g> <g class="dg-l1"><text x="102" y="107" font-size="15" class="dg-ink" fill="#0369a1" font-weight="700">Your laptop or phone</text></g> <text x="62" y="138" font-size="13" class="dg-muted" fill="#5c5c68" font-weight="500">Has a screen and a keyboard</text> <text x="62" y="158" font-size="13" class="dg-muted" fill="#5c5c68" font-weight="500">Switched off or asleep part of the day</text> <rect class="dg-card" x="656" y="70" width="340" height="120" rx="12" fill="#ffffff" stroke="#cfcfc8"/> <g class="dg-l2"><g class="dg-icon" transform="translate(672 86) scale(1.2500)" fill="none" stroke="#15803d" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><rect width="20" height="8" x="2" y="2" rx="2"/><rect width="20" height="8" x="2" y="14" rx="2"/><path d="M6 6h.01"/><path d="M6 18h.01"/></g></g> <g class="dg-l2"><text x="714" y="107" font-size="15" class="dg-ink" fill="#15803d" font-weight="700">Any computer in the server role</text></g> <text x="674" y="138" font-size="13" class="dg-muted" fill="#5c5c68" font-weight="500">Waits for requests and answers them</text> <text x="674" y="158" font-size="13" class="dg-muted" fill="#5c5c68" font-weight="500">A laptop can do this too, for a while</text> <g class="dg-l1"><path class="dg-stroke" d="M412 100H622" stroke="#0369a1" stroke-width="2.5" fill="none" stroke-linecap="round" stroke-linejoin="round"/></g> <g class="dg-l1"><path class="dg-stroke" d="M614 94l8 6-8 6" stroke="#0369a1" stroke-width="2.5" fill="none" stroke-linecap="round" stroke-linejoin="round"/></g> <g class="dg-l2"><path class="dg-stroke" d="M628 160H418" stroke="#15803d" stroke-width="2.5" fill="none" stroke-linecap="round" stroke-linejoin="round"/></g> <g class="dg-l2"><path class="dg-stroke" d="M426 154l-8 6 8 6" stroke="#15803d" stroke-width="2.5" fill="none" stroke-linecap="round" stroke-linejoin="round"/></g> <g class="dg-l1"><rect class="dg-bg-plain" x="427.84" y="66" width="184.32" height="24" rx="12" fill="#ffffff"/><text x="520" y="82.5" font-size="11" class="dg-ink" fill="#0369a1" font-weight="600" text-anchor="middle">request: "show me the page"</text></g> <g class="dg-l2"><rect class="dg-bg-plain" x="452.48" y="126" width="135.04" height="24" rx="12" fill="#ffffff"/><text x="520" y="142.5" font-size="11" class="dg-ink" fill="#15803d" font-weight="600" text-anchor="middle">response: the files</text></g> <text x="24" y="248" font-size="12.5" class="dg-muted" fill="#5c5c68" font-weight="700">WHY REAL SERVERS LIVE IN DATA CENTRES</text> <rect class="dg-card" x="24" y="264" width="188.8" height="100" rx="12" fill="#ffffff" stroke="#cfcfc8"/> <g class="dg-l3"><g class="dg-icon" transform="translate(40 280) scale(1.2500)" fill="none" stroke="#b45309" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><path d="M12 6v6l4 2"/></g></g> <g class="dg-l3"><text x="82" y="301" font-size="14" class="dg-ink" fill="#b45309" font-weight="700">Always on</text></g> <text x="42" y="332" font-size="13" class="dg-muted" fill="#5c5c68" font-weight="500">Answers at 3 a.m. too</text> <rect class="dg-card" x="224.8" y="264" width="188.8" height="100" rx="12" fill="#ffffff" stroke="#cfcfc8"/> <g class="dg-l3"><g class="dg-icon" transform="translate(240.8 280) scale(1.2500)" fill="none" stroke="#b45309" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M13 2 3 14h9l-1 8 10-12h-9z"/></g></g> <g class="dg-l3"><text x="282.8" y="301" font-size="14" class="dg-ink" fill="#b45309" font-weight="700">Reliable power</text></g> <text x="242.8" y="332" font-size="13" class="dg-muted" fill="#5c5c68" font-weight="500">Backup batteries,</text> <text x="242.8" y="352" font-size="13" class="dg-muted" fill="#5c5c68" font-weight="500">generators</text> <rect class="dg-card" x="425.6" y="264" width="188.8" height="100" rx="12" fill="#ffffff" stroke="#cfcfc8"/> <g class="dg-l3"><g class="dg-icon" transform="translate(441.6 280) scale(1.2500)" fill="none" stroke="#b45309" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M2 12h20"/><path d="M12 2v20"/><path d="m4.9 4.9 14.2 14.2"/><path d="m19.1 4.9-14.2 14.2"/></g></g> <g class="dg-l3"><text x="483.6" y="301" font-size="14" class="dg-ink" fill="#b45309" font-weight="700">Cooling</text></g> <text x="443.6" y="332" font-size="13" class="dg-muted" fill="#5c5c68" font-weight="500">Many machines</text> <text x="443.6" y="352" font-size="13" class="dg-muted" fill="#5c5c68" font-weight="500">make a lot of heat</text> <rect class="dg-card" x="626.4" y="264" width="188.8" height="100" rx="12" fill="#ffffff" stroke="#cfcfc8"/> <g class="dg-l3"><g class="dg-icon" transform="translate(642.4 280) scale(1.2500)" fill="none" stroke="#b45309" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M12 20h.01"/><path d="M2 8.82a15 15 0 0 1 20 0"/><path d="M5 12.86a10 10 0 0 1 14 0"/><path d="M8.5 16.43a5 5 0 0 1 7 0"/></g></g> <g class="dg-l3"><text x="684.4" y="301" font-size="14" class="dg-ink" fill="#b45309" font-weight="700">Fast connection</text></g> <text x="644.4" y="332" font-size="13" class="dg-muted" fill="#5c5c68" font-weight="500">Several links to</text> <text x="644.4" y="352" font-size="13" class="dg-muted" fill="#5c5c68" font-weight="500">the Internet</text> <rect class="dg-card" x="827.2" y="264" width="188.8" height="100" rx="12" fill="#ffffff" stroke="#cfcfc8"/> <g class="dg-l3"><g class="dg-icon" transform="translate(843.2 280) scale(1.2500)" fill="none" stroke="#b45309" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><rect width="20" height="14" x="2" y="3" rx="2"/><path d="M8 21h8"/><path d="M12 17v4"/><path d="m3 3 18 18"/></g></g> <g class="dg-l3"><text x="885.2" y="301" font-size="14" class="dg-ink" fill="#b45309" font-weight="700">No screen</text></g> <text x="845.2" y="332" font-size="13" class="dg-muted" fill="#5c5c68" font-weight="500">Managed from far away</text> </svg></figure> *Figure 1. The client asks and the server answers; real servers live in data centres because they must be always available.* If any computer can be a server, why do the servers behind famous websites sit in special buildings? Because a server must answer whenever someone asks, so it needs things a laptop on your desk does not have. A **data centre** is a building made to host many servers, and it provides: - **Always on.** Visitors arrive at 3 a.m. too. A laptop that sleeps or is switched off cannot answer. - **Reliable power.** Batteries and generators keep the machines running during a power cut. - **Cooling.** Many machines in one room make a lot of heat, and hot machines break. - **A fast connection.** Several links to the Internet, so many visitors can be served at once and one broken cable does not cut everything off. - **No screen.** Servers are managed from far away, so they usually have no screen or keyboard at all. A server is therefore a role that any computer can play, but one that is played best by a machine that is always on, powered, cooled and well connected. > [!CHECK] > Which sentence about servers is true? > > - [ ] A server is always a special, expensive machine that cannot be used for anything else. > - [x] A server is any computer that waits for requests and answers them. > - [ ] A computer with a screen and keyboard can never be a server. > - [ ] A server is the same thing as a website. > > "Server" describes a role. Your laptop plays that role while it runs a program that answers requests. A website is the content a server serves, not the server itself. ### What happens when you type an address When you type `www.example.com` and press Enter, four things happen in a fraction of a second. <figure class="diagram" style="--dg-w: 1040px"><svg xmlns="http://www.w3.org/2000/svg" class="dg" viewBox="0 0 1040 459" width="1040" height="459" role="img" aria-labelledby="webserver-flow-title webserver-flow-desc" font-family="Inter, system-ui, -apple-system, Segoe UI, Roboto, sans-serif" xml:lang="en"> <title id="webserver-flow-title">What happens when you type a web address</title> <desc id="webserver-flow-desc">A sequence diagram with three actors: your browser, the name service (DNS), which works like a phone book, and the web server at 192.0.2.10. Step 1: the browser asks the name service where www.example.com is. Step 2: the name service answers that it is at 192.0.2.10. Step 3: the browser sends an HTTP request to the web server, GET slash, meaning please send me the home page. Step 4: the web server sends an HTTP response, 200 OK, with the file index.html and then the images. Finally, the browser reads the files and draws the page.</desc> <rect class="dg-bg" x="0.5" y="0.5" width="1039" height="458" rx="16" fill="#ffffff" stroke="#e3e3dd"/> <path class="dg-line" d="M150 98V443" stroke="#cfcfc8" stroke-width="1.5" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-dasharray="7 6"/> <path class="dg-line" d="M520 98V443" stroke="#cfcfc8" stroke-width="1.5" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-dasharray="7 6"/> <path class="dg-line" d="M890 98V443" stroke="#cfcfc8" stroke-width="1.5" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-dasharray="7 6"/> <rect class="dg-card" x="45" y="24" width="210" height="74" rx="12" fill="#ffffff" stroke="#cfcfc8"/> <g class="dg-l1"><g class="dg-icon" transform="translate(59 38) scale(1.1667)" fill="none" stroke="#0369a1" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M20 16V7a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v9m16 0H4m16 0 1.28 2.55a1 1 0 0 1-.9 1.45H3.62a1 1 0 0 1-.9-1.45L4 16"/></g></g> <text x="97" y="56" font-size="14" class="dg-text" fill="#17171c" font-weight="700">Your browser</text> <text x="97" y="76" font-size="12" class="dg-muted" fill="#5c5c68" font-weight="500">you</text> <rect class="dg-card" x="415" y="24" width="210" height="74" rx="12" fill="#ffffff" stroke="#cfcfc8"/> <g class="dg-l7"><g class="dg-icon" transform="translate(429 38) scale(1.1667)" fill="none" stroke="#6d28d9" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M4 6h16"/><path d="M4 12h10"/><path d="M4 18h6"/><circle cx="18" cy="16" r="3"/><path d="m22 20-1.8-1.8"/></g></g> <text x="467" y="56" font-size="14" class="dg-text" fill="#17171c" font-weight="700">Name service (DNS)</text> <text x="467" y="76" font-size="12" class="dg-muted" fill="#5c5c68" font-weight="500">the phone book</text> <rect class="dg-card" x="785" y="24" width="210" height="74" rx="12" fill="#ffffff" stroke="#cfcfc8"/> <g class="dg-l2"><g class="dg-icon" transform="translate(799 38) scale(1.1667)" fill="none" stroke="#15803d" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><rect width="20" height="8" x="2" y="2" rx="2"/><rect width="20" height="8" x="2" y="14" rx="2"/><path d="M6 6h.01"/><path d="M6 18h.01"/></g></g> <text x="837" y="56" font-size="14" class="dg-text" fill="#17171c" font-weight="700">Web server</text> <text x="837" y="76" font-size="12" class="dg-muted" fill="#5c5c68" font-weight="500" font-family="JetBrains Mono, ui-monospace, Menlo, Consolas, monospace">192.0.2.10</text> <text x="335" y="128" font-size="12.5" class="dg-text" fill="#17171c" font-weight="600" text-anchor="middle">Where is www.example.com?</text> <text x="335" y="145" font-size="12.5" class="dg-text" fill="#17171c" font-weight="500" text-anchor="middle">(the name is looked up)</text> <g class="dg-l7"><circle class="dg-solid" cx="223.25" cy="124" r="11" fill="#6d28d9"/><text x="223.25" y="128.5" font-size="12" class="dg-on" fill="#ffffff" font-weight="700" text-anchor="middle">1</text></g> <g class="dg-l7"><path class="dg-stroke" d="M154 159H514" stroke="#6d28d9" stroke-width="2.5" fill="none" stroke-linecap="round" stroke-linejoin="round"/></g> <g class="dg-l7"><path class="dg-stroke" d="M506 153l8 6-8 6" stroke="#6d28d9" stroke-width="2.5" fill="none" stroke-linecap="round" stroke-linejoin="round"/></g> <text x="335" y="197" font-size="12.5" class="dg-text" fill="#17171c" font-weight="600" text-anchor="middle">It is at 192.0.2.10</text> <text x="335" y="214" font-size="12.5" class="dg-text" fill="#17171c" font-weight="500" text-anchor="middle">(the address)</text> <g class="dg-l7"><circle class="dg-solid" cx="245.75" cy="193" r="11" fill="#6d28d9"/><text x="245.75" y="197.5" font-size="12" class="dg-on" fill="#ffffff" font-weight="700" text-anchor="middle">2</text></g> <g class="dg-l7"><path class="dg-stroke" d="M516 228H156" stroke="#6d28d9" stroke-width="2.5" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-dasharray="7 6"/></g> <g class="dg-l7"><path class="dg-stroke" d="M164 222l-8 6 8 6" stroke="#6d28d9" stroke-width="2.5" fill="none" stroke-linecap="round" stroke-linejoin="round"/></g> <text x="520" y="266" font-size="12.5" class="dg-text" fill="#17171c" font-weight="600" text-anchor="middle">GET / (the HTTP request)</text> <text x="520" y="283" font-size="12.5" class="dg-text" fill="#17171c" font-weight="500" text-anchor="middle">"please send me the home page"</text> <g class="dg-l1"><circle class="dg-solid" cx="412" cy="262" r="11" fill="#0369a1"/><text x="412" y="266.5" font-size="12" class="dg-on" fill="#ffffff" font-weight="700" text-anchor="middle">3</text></g> <g class="dg-l1"><path class="dg-stroke" d="M154 297H884" stroke="#0369a1" stroke-width="2.5" fill="none" stroke-linecap="round" stroke-linejoin="round"/></g> <g class="dg-l1"><path class="dg-stroke" d="M876 291l8 6-8 6" stroke="#0369a1" stroke-width="2.5" fill="none" stroke-linecap="round" stroke-linejoin="round"/></g> <text x="520" y="335" font-size="12.5" class="dg-text" fill="#17171c" font-weight="600" text-anchor="middle">200 OK (the HTTP response)</text> <text x="520" y="352" font-size="12.5" class="dg-text" fill="#17171c" font-weight="500" text-anchor="middle">index.html, then the images</text> <g class="dg-l2"><circle class="dg-solid" cx="404.5" cy="331" r="11" fill="#15803d"/><text x="404.5" y="335.5" font-size="12" class="dg-on" fill="#ffffff" font-weight="700" text-anchor="middle">4</text></g> <g class="dg-l2"><path class="dg-stroke" d="M886 366H156" stroke="#15803d" stroke-width="2.5" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-dasharray="7 6"/></g> <g class="dg-l2"><path class="dg-stroke" d="M164 360l-8 6 8 6" stroke="#15803d" stroke-width="2.5" fill="none" stroke-linecap="round" stroke-linejoin="round"/></g> <g class="dg-ok"><rect class="dg-tint" x="110" y="388" width="820" height="31" rx="8" fill="#e8f2ec" stroke="#96c6a8" stroke-width="1.2"/> <text x="520" y="405" font-size="12.5" class="dg-ink" fill="#15803d" font-weight="600" text-anchor="middle">The browser reads the files and draws the page</text> </g> </svg></figure> *Figure 2. First the name is turned into an address, then the page is requested, then the files come back.* **1. The name is looked up.** Computers find each other by numbers called **IP addresses**, such as `192.0.2.10`, but people prefer names. The **Domain Name System (DNS)** works like a phone book: you give it a name and it gives back the number. Your browser asks it where `www.example.com` is, and it answers `192.0.2.10`. (The addresses in this lesson come from a range reserved for examples, so they are safe to show.) **2. The browser sends a request.** The browser now knows where the server is and sends a message to it using **HTTP** (HyperText Transfer Protocol), the language of the web. A request has a **method** and a **path**. The most common method is `GET`, which means "please send me this". The path says what you want: `/` is the home page. So the request is, in essence, `GET /`. **3. The server sends back files.** The server finds the right files and answers with a **status code** and the content. `200 OK` means "here it is". A page is usually several files: an **HTML** file (HyperText Markup Language), which holds the text and structure of the page, plus images and other files it refers to. The browser asks for each of those files in the same way. **4. The browser draws the page.** The browser reads the HTML, puts the images in place and shows you the result. The server never draws anything. It only sends files, and your browser does the drawing. Other status codes you will meet: `404 Not Found` means "I have no file at that path", and `500 Internal Server Error` means "something broke on my side". The first digit is the family: 2 success, 4 a problem with the request (often the address), 5 a problem on the server. > [!CHECK] > In the phone-book comparison, what does DNS give your browser? > > - [ ] The web page itself > - [x] The IP address that goes with a name > - [ ] A password for the website > - [ ] A faster connection > > DNS only turns a name into an address. The page itself comes afterwards, from the web server. > [!CHECK] > A browser shows "404 Not Found". What does it mean? > > - [ ] The server is switched off. > - [ ] Your Internet connection is broken. > - [x] The server is working, but it has no page at that address. > - [ ] The page is blocked because it is dangerous. > > A 404 is an answer, so a server must be running. It only says there is nothing at that path, often because of a typing mistake in the address. ### HTTP, HTTPS and the padlock Plain HTTP sends everything as readable text. Anyone who can see the traffic on the way, such as the owner of a shared Wi-Fi network, could read it or change it. **HTTPS** is HTTP inside an encrypted connection. **Encryption** scrambles the data so that only the two ends can read it. The browser also checks a **certificate**, a digital document that proves the server really belongs to the name in the address bar. Browsers show a padlock for HTTPS. Be careful about what it promises. It means: "your connection to *this exact name* is encrypted, and the name was checked". It does **not** mean the site is honest. A scammer can get a certificate for `my-bank-login.example` just as easily as a real shop can. Read the name in the address bar, not only the padlock. ### Ports: the door numbers One server can offer several services at once, just as one building has many doors. A **port** is a number that says which door a request is knocking on. Web servers listen on two well-known ports: | Port | Used for | |---|---| | 80 | HTTP | | 443 | HTTPS | You normally don't see these numbers because the browser adds them for you: `https://` means port 443 and `http://` means port 80. When a server uses another port, you write it after the address with a colon, for example `http://127.0.0.1:8000`. In the activities you will use port 8000 to avoid interfering with anything else on your computer. (`127.0.0.1` is a special address that always means "this computer".) > [!CHECK] > A site's address starts with `https://` and shows a padlock. What does the padlock guarantee? > > - [ ] The owner of the site is honest. > - [ ] The site contains no viruses. > - [x] The connection to that name is encrypted and the name was checked. > - [ ] The site was approved by the government. > > The padlock protects the connection, not the intentions of the owner. Fraudulent sites can use HTTPS too. ### Ways to publish a website Once you have the files for a site, where do you put them so the world can reach them? There are four common answers, from most work for you to least. <figure class="diagram" style="--dg-w: 1040px"><svg xmlns="http://www.w3.org/2000/svg" class="dg" viewBox="0 0 1040 260" width="1040" height="260" role="img" aria-labelledby="webserver-options-title webserver-options-desc" font-family="Inter, system-ui, -apple-system, Segoe UI, Roboto, sans-serif" xml:lang="en"> <title id="webserver-options-title">Four ways to publish a website</title> <desc id="webserver-options-desc">Four cards in a row, from more work for you on the left to less work for you on the right. Your own computer: you do everything, it is off when you are off, and home connections are not built for it. Shared web hosting: you rent a small space on a server shared with others, which is easy but gives little control. Rented virtual server: your own server to look after, with updates, security and backups, giving full control and more work. Cloud or static hosting: you upload your files and the provider runs everything and grows with visitors, and you pay for what you use.</desc> <rect class="dg-bg" x="0.5" y="0.5" width="1039" height="259" rx="16" fill="#ffffff" stroke="#e3e3dd"/> <rect class="dg-card" x="24" y="24" width="236" height="150" rx="12" fill="#ffffff" stroke="#cfcfc8"/> <g class="dg-l4"><g class="dg-icon" transform="translate(40 40) scale(1.2500)" fill="none" stroke="#c2410c" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M20 16V7a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v9m16 0H4m16 0 1.28 2.55a1 1 0 0 1-.9 1.45H3.62a1 1 0 0 1-.9-1.45L4 16"/></g></g> <g class="dg-l4"><text x="82" y="61" font-size="14.5" class="dg-ink" fill="#c2410c" font-weight="700">Your own computer</text></g> <text x="42" y="92" font-size="13" class="dg-muted" fill="#5c5c68" font-weight="500">You do everything</text> <text x="42" y="112" font-size="13" class="dg-muted" fill="#5c5c68" font-weight="500">Off when you are off; home</text> <text x="42" y="132" font-size="13" class="dg-muted" fill="#5c5c68" font-weight="500">connections are not built for it</text> <rect class="dg-card" x="276" y="24" width="236" height="150" rx="12" fill="#ffffff" stroke="#cfcfc8"/> <g class="dg-l3"><g class="dg-icon" transform="translate(292 40) scale(1.2500)" fill="none" stroke="#b45309" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"/><circle cx="9" cy="7" r="4"/><path d="M22 21v-2a4 4 0 0 0-3-3.87"/><path d="M16 3.13a4 4 0 0 1 0 7.75"/></g></g> <g class="dg-l3"><text x="334" y="61" font-size="14.5" class="dg-ink" fill="#b45309" font-weight="700">Shared web hosting</text></g> <text x="294" y="92" font-size="13" class="dg-muted" fill="#5c5c68" font-weight="500">Rent a small space on a</text> <text x="294" y="112" font-size="13" class="dg-muted" fill="#5c5c68" font-weight="500">server shared with others</text> <text x="294" y="132" font-size="13" class="dg-muted" fill="#5c5c68" font-weight="500">Easy, little control</text> <rect class="dg-card" x="528" y="24" width="236" height="150" rx="12" fill="#ffffff" stroke="#cfcfc8"/> <g class="dg-l1"><g class="dg-icon" transform="translate(544 40) scale(1.2500)" fill="none" stroke="#0369a1" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><rect width="20" height="8" x="2" y="2" rx="2"/><rect width="20" height="8" x="2" y="14" rx="2"/><path d="M6 6h.01"/><path d="M6 18h.01"/></g></g> <g class="dg-l1"><text x="586" y="61" font-size="14.5" class="dg-ink" fill="#0369a1" font-weight="700">Rented virtual server</text></g> <text x="546" y="92" font-size="13" class="dg-muted" fill="#5c5c68" font-weight="500">Your own server to look after:</text> <text x="546" y="112" font-size="13" class="dg-muted" fill="#5c5c68" font-weight="500">updates, security, backups</text> <text x="546" y="132" font-size="13" class="dg-muted" fill="#5c5c68" font-weight="500">Full control, more work</text> <rect class="dg-card" x="780" y="24" width="236" height="150" rx="12" fill="#ffffff" stroke="#cfcfc8"/> <g class="dg-l2"><g class="dg-icon" transform="translate(796 40) scale(1.2500)" fill="none" stroke="#15803d" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z"/></g></g> <g class="dg-l2"><text x="838" y="61" font-size="14.5" class="dg-ink" fill="#15803d" font-weight="700">Cloud / static hosting</text></g> <text x="798" y="92" font-size="13" class="dg-muted" fill="#5c5c68" font-weight="500">Upload your files; the provider</text> <text x="798" y="112" font-size="13" class="dg-muted" fill="#5c5c68" font-weight="500">runs everything, grows with</text> <text x="798" y="132" font-size="13" class="dg-muted" fill="#5c5c68" font-weight="500">visitors, pay for what you use</text> <g class="dg-l1"><path class="dg-stroke" d="M34 210H1000" stroke="#0369a1" stroke-width="2" fill="none" stroke-linecap="round" stroke-linejoin="round"/></g> <g class="dg-l1"><path class="dg-stroke" d="M992 204l8 6-8 6" stroke="#0369a1" stroke-width="2.5" fill="none" stroke-linecap="round" stroke-linejoin="round"/></g> <text x="34" y="236" font-size="12.5" class="dg-muted" fill="#5c5c68" font-weight="700">more control, more work for you</text> <text x="1000" y="236" font-size="12.5" class="dg-muted" fill="#5c5c68" font-weight="700" text-anchor="end">less work for you, less control</text> </svg></figure> *Figure 3. The more the provider does for you, the less you control and the less you have to look after.* | Option | What it is | Good for | Trade-offs | |---|---|---|---| | Your own computer | You run the server on a computer at home | Learning and testing | Off when you are off; your home connection and address are not built for visitors; you must secure it yourself | | Shared web hosting | You rent a small space on a server that many customers share | A simple small site, with help from the provider | Easy to start; limited control; a busy neighbour can slow you down | | Rented virtual server | You rent your own **virtual server**, a slice of a powerful machine that behaves like a computer of your own | Custom software and full control | You install updates, set up security and make backups | | Cloud or static hosting | You upload your files and the provider runs and grows everything | Sites made only of files, and sites that may get many visitors | You depend on the provider's way of working; costs follow usage, so check them | None of these is "the best". Your own computer is excellent for learning, which is why you start there. > [!NOTE] > Prices and features change and differ between providers, so this lesson names none. Ask the same questions of every offer: who installs updates, who makes backups, what happens if many visitors come, and what does it cost per month? > [!CHECK] > A bakery wants a simple page with opening hours and no technical work. Which option fits best? > > - [ ] Run a server on the owner's laptop at home. > - [x] Static or shared hosting, where the provider runs the server. > - [ ] A rented virtual server that the owner maintains. > - [ ] Build a data centre. > > The owner only has files to publish, so a service that looks after the server avoids updates, security tasks and downtime. ## How it works Putting the pieces together, the journey of a single page view looks like this: 1. You type `https://www.example.com/` and press Enter. 2. The browser asks DNS for the address of `www.example.com` and receives, for example, `192.0.2.10`. 3. It connects to that address on port 443 and sets up an encrypted connection, checking the certificate. 4. It sends `GET /`. 5. The server answers `200 OK` and sends the HTML file. The browser then requests the images and other files the page uses. 6. The browser draws the page. The padlock tells you the connection was encrypted. Every step can fail on its own. A wrong name fails at step 2, a switched-off server fails at step 3, and a missing file gives a 404 at step 5. ## Worked example Mia runs a small bakery and wants a page with her opening hours. - Her page is one HTML file and two photos: no special software. - Running a server on her home computer would mean the site disappears whenever she turns it off, so she rejects that. - A rented virtual server would give her control she doesn't need and chores she doesn't want. - She picks static hosting: she uploads the three files, the provider serves them over HTTPS, and she buys the name `mias-bakery.example` so customers can type it. ## Common pitfalls - **"The padlock means the site is safe."** — It only means the connection is encrypted and the name was checked. Always read the name too. - **"The server is the website."** — A website is files and content; a server is the computer that serves them. One server can host many websites. - **"A server must be a huge machine."** — Any computer can play the role, and for a small test your laptop is enough. ## Security considerations - **Prefer HTTPS** for every site you publish or use, especially where you type passwords or personal details. - **Check the name** in the address bar before entering a password. Look-alike names are a common trick. - **A server answers anyone who can reach it.** If you run one on your own computer, keep it for learning and local use, and stop it when you are done. In the activities you restrict it to your own computer with `127.0.0.1`. - **Update what you run.** A rented server is yours to patch; shared and cloud hosting usually do it for you. ## Summary - A server is a role: any computer that waits for requests and answers them. Data centres give real servers power, cooling, speed and constant availability. - Opening a page means: the name is looked up (DNS), the browser sends an HTTP request, the server sends back files, and the browser draws the page. - HTTPS encrypts the connection and checks the name; the padlock does not mean the site is honest. Web servers use port 80 for HTTP and port 443 for HTTPS. - You can publish from your own computer, shared hosting, a rented virtual server or cloud and static hosting. More help from the provider means less work and less control. ## Glossary | Term | Definition | |---|---| | server | A computer that waits for requests and answers them. | | client | A computer, phone or program that asks a server for something. | | protocol | A set of agreed rules for how two computers talk to each other. | | data centre | A building made to host many servers, with reliable power, cooling and fast connections. | | IP address | The number that identifies a computer on a network, such as `192.0.2.10`. | | Domain Name System (DNS) | The Internet's phone book: it turns a name into an IP address. | | HTTP | HyperText Transfer Protocol, the language browsers and web servers use to ask for and send pages. | | method | The first word of an HTTP request that says what to do; `GET` means "send me this". | | path | The part of the address that says which page or file you want, such as `/` or `/about.html`. | | status code | A number in the server's answer: 200 means OK, 404 means not found, 500 means a server problem. | | HTML | HyperText Markup Language, the file format that holds the text and structure of a web page. | | HTTPS | HTTP inside an encrypted connection. | | encryption | Scrambling data so that only the intended ends can read it. | | certificate | A digital document that proves a server belongs to the name in the address bar. | | port | A number that says which service on a computer a request is for; web servers use 80 (HTTP) and 443 (HTTPS). | | virtual server | A slice of a powerful machine that behaves like a computer of your own. | ## Check your understanding 1. Your friend says, "My laptop can never be a server." What would you answer, and why would you still not use it to host a shop? 2. Explain in your own words what happens between typing `www.example.com` and seeing the page. Use the words "name", "request" and "response". 3. Why would a bakery with a one-page site probably not need a rented virtual server? ## References - [What is a web server? — Mozilla Developer Network](https://developer.mozilla.org/en-US/docs/Learn_web_development/Howto/Web_mechanics/What_is_a_web_server) - RFC 9110: HTTP Semantics (methods and status codes) - RFC 5737: IPv4 Address Blocks Reserved for Documentation