Lesson 18 / الدرس 18

Hosting: where a site actually lives / الاستضافة: أين يعيش الموقع فعلًا

Behind every domain is a machine somewhere with your files on it, running a program that answers requests. What you are choosing when you choose a host is how much of that machine is yours.

خلف كل نطاق جهاز في مكان ما عليه ملفاتك، يشغّل برنامجًا يجيب الطلبات. وما تختاره حين تختار مستضيفًا هو كم من ذلك الجهاز يخصك.

A site is files plus a program that serves them. The program — Apache, nginx or similar — listens on port 443, matches the path in the request to something on disk, and writes back the response from lesson 8. Hosting is renting a machine that keeps that program running.

Four kinds, from least to most yours

KindYou getSuits
SharedA folder on a machine with hundreds of other sitesA first site, a small business
Virtual private serverA slice of a machine, with root accessWhen you need to install things
DedicatedThe whole machineHeavy or sensitive work
Static hostingFiles only, no server program of your ownSites with no server-side code

This course is on shared hosting, which is why lesson 5 could say honestly that an address often names a machine holding hundreds of sites. It is the cheapest and, for most sites, entirely adequate.

One folder on that machine is special: the document root, usually called public_html or www. Only what is inside it can be reached from the web. A request for /about.html is answered with the file of that name inside the document root, and nothing outside it can be requested at all — which is exactly where passwords and configuration should live.

home/
├── config.php        ← passwords live here, unreachable from the web
├── src/              ← your code, unreachable from the web
└── public_html/      ← the document root
    ├── index.html    ← https://example.com/
    ├── about.html    ← https://example.com/about.html
    └── assets/       ← https://example.com/assets/…
The layout this very site uses. Run it and label each line: what a visitor can reach and what they cannot. Getting this boundary right is the whole of basic server security.

Static and dynamic

If the file on disk is what the visitor gets, the site is static — the pages you built in the HTML course are exactly this. If a program runs on each request and builds the page fresh, it is dynamic. This site is dynamic: no file called hosting.php sits in the document root, and this page was assembled when you asked for it.

Try it live / جرّب بنفسك

Preview / المعاينة

Check yourself / اختبر نفسك

1. Where should a file holding a database password live?

2. What makes a site dynamic rather than static?

3. Why must uploaded files be stored outside the document root?

Your task / مهمتك

Draw the folder layout of a hosted site on a page: what sits inside the document root and what sits outside it, with the web address beside each public file. Then add a short section comparing shared hosting with a virtual private server, and say which you would choose for a first site and why.

ارسم تخطيط مجلدات موقع مستضاف في صفحة: ما داخل جذر المستندات وما خارجه، مع عنوان الويب بجانب كل ملف عام. ثم أضف قسمًا قصيرًا يقارن الاستضافة المشتركة بخادم افتراضي خاص، وقل أيهما تختار لموقع أول ولماذا.

  • Public and private clearly separated العام والخاص مفصولان بوضوح
  • Each public file has its web address beside it كل ملف عام بجانبه عنوانه على الويب
  • A comparison with a stated choice and a reason مقارنة مع اختيار معلن وسبب
How do you want to submit? / كيف تريد التسليم؟