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
| Kind | You get | Suits |
|---|---|---|
| Shared | A folder on a machine with hundreds of other sites | A first site, a small business |
| Virtual private server | A slice of a machine, with root access | When you need to install things |
| Dedicated | The whole machine | Heavy or sensitive work |
| Static hosting | Files only, no server program of your own | Sites 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.
public_html أو www. ولا يُبلَغ من الويب إلا ما بداخله. فطلب /about.html يُجاب بالملف بذلك الاسم داخل جذر المستندات، ولا يمكن طلب أي شيء خارجه إطلاقًا — وهذا بالضبط حيث ينبغي أن تعيش كلمات المرور والإعدادات.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/…
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.
hosting.php، وقد جُمّعت هذه الصفحة حين طلبتها.Try it live / جرّب بنفسك
Check yourself / اختبر نفسك
1. Where should a file holding a database password live?
Only what is inside the document root can be requested. Putting secrets one level up is not a trick — it is the boundary working as designed.
2. What makes a site dynamic rather than static?
The distinction is whether a file on disk is the answer. Animation happens in the browser and has nothing to do with it.
3. Why must uploaded files be stored outside the document root?
A public folder plus an upload form is a way to hand a stranger the right to execute code on your server. Serve uploads through your own code instead.
Score / النتيجة: 0 / 3
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 مقارنة مع اختيار معلن وسبب