Ravindra BagaleCourses & study guides मराठी Track your progress

AWS Cloud

Chapter 7: Static Website Hosting (3 OSes × 2 Web Servers)

Come on, friends, this chapter is very special – today your own web page will appear live on the internet for the first time. In my class this moment is always special! Example: a small static website of a dairy brand like Amul (sample data, for practice) – daily milk rates and a contact page. Three OSes and two web servers, that is six combinations, but the idea is the same everywhere: reviewed public files, a configuration that maps requests to them, suitable permissions, and verification. Test and reload when configuration changes require it; ordinary content changes do not always need a reload. Choose your OS and do it step by step with me.

In this chapter

  • What a static website is
  • The six hosting combinations
  • Creating and uploading files
  • File and directory permissions, serving identity and access
  • Server blocks and vhosts
  • SELinux and firewalld on CentOS
  • Many sites on one server
  • HTTPS and troubleshooting

Concepts in this chapter

  1. 7.1Why and what
  2. 7.2The hosting matrix
  3. 7.3Step 1 (common): create the sample website
  4. 7.4Step 2 (common): ways to upload your own files
  5. 7.5Step 3 (common): copy files and set permissions
  6. 7.6Combination 1 — Amazon Linux 2023 + Nginx
  7. 7.7Combination 2 — Amazon Linux 2023 + Apache
  8. 7.8Combination 3 — Ubuntu + Nginx
  9. 7.9Combination 4 — Ubuntu + Apache
  10. 7.10Combination 5 — CentOS Stream 9 + Nginx
  11. 7.11Combination 6 — CentOS Stream 9 + Apache
  12. 7.12Hosting multiple sites on one server (virtual hosts)
  13. 7.13Adding HTTPS (optional, needs a domain)
  14. 7.14Troubleshooting static sites

Review and practice

  1. ★Common Mistakes I See Students Make
  2. ★Interview Questions
  3. ★Practice Questions and Lab Exercises

Follow a timetable release from files to students

Follow a timetable release from files to studentsPublic file setHTML, CSS, map and room pageStaged candidatePredict and test asset pathsPublished releaseName, mapping and accessVerified resultMarker, display and recovery
Read all steps
  1. Public file set

    Identify the complete reviewed output and keep private configuration outside it. The home page and its referenced assets belong to one release.

  2. Staged candidate

    Preview the candidate through HTTP. Test the home page, a nested page, styles and images, and a missing resource before selecting the release for visitors.

  3. Published release

    Connect the intended hostname and web-server configuration to the approved release. Verify the real serving identity and response path rather than only the upload result.

  4. Verified result

    Compare the release marker, expected content, assets and mobile display. Keep the previous working release and demonstrate the request results after a rollback.

Publish one dependable workshop timetable

A department coordinator sends a revised workshop timetable to a group of students. Some students keep the old attachment, others forward a screenshot, and another student asks which version is correct. A small website gives the department one publishing location and gives students one address to check. The practical requirement is simple: the approved timetable, room directions and contact information should arrive together, display clearly on a phone and remain easy to update or restore.

This is an excellent first static-hosting project. The content can be prepared before a visitor requests it. HTML describes the timetable and links, CSS controls its appearance, and an image can show the workshop room. Hosting makes those published files available through a web-serving system. In this chapter, the system is Nginx or Apache on a Linux host. Managed hosting services can serve static content too; learning these six Linux and web-server combinations helps you understand the underlying responsibilities.

The goal is more demanding than copying one HTML file into a folder. A successful deployment includes every required asset, correct paths, suitable access, the intended site configuration and a way to recognize the published version. If the home page loads but its room map is missing, the student's task is still incomplete. If a new timetable appears while the old contact details remain, the deployment contains a mixture of releases.

We will follow the files from preparation to verification and publication. You will learn to distinguish a source project from its publishable output, predict how a URL maps to a file, and diagnose a missing asset without changing unrelated settings. A contained local lab gives you a complete miniature website. The operating-system lessons then apply the same reasoning to their particular package names, paths and service commands.

Understand which work happens before and after a request

Static describes how the server obtains the content for a request. For an ordinary static file, the representation already exists and the server can deliver it without running the workshop's business logic to produce that representation. The file can still be revised many times. Static does not mean permanent, uninteresting or limited to plain text. A carefully designed information site can contain navigation, illustrations, searchable material and responsive layouts.

Browser JavaScript can add interaction after files arrive. For example, a script can filter a timetable already included in the page by department or date. That interaction does not require the server to generate a new personalized timetable for every click. If the script calls an API to reserve a seat, the reservation depends on a separate backend. The page files may be statically hosted while the wider application includes dynamic services.

A server-side dynamic page takes a different path. Application code may inspect a login session, query a database and construct a response for that request. Publishing PHP source as an ordinary static download does not execute it safely as an application. Similarly, placing a Python program under a public document root does not automatically make it a working API. Identify the execution environment and request handler before assuming a file extension enables a feature.

Build time is another separate stage. A static-site generator can read templates and content, then generate finished HTML before deployment. A frontend build can bundle JavaScript, optimize CSS and assign versioned asset names. The output can still be served statically even though software created it. The distinction is about when and where processing occurs: during preparation, on the server for a request, or inside the visitor's browser.

For our timetable, choose the simplest arrangement that satisfies the requirement. If the coordinator updates a published schedule once a week, static files may be enough. If each student must log in and see private bookings, additional authentication and application behavior are needed. Do not hide private student information in JavaScript and assume it is protected because the page initially conceals it. Anything delivered to the browser must be treated as available to that browser's user.

Prepare the folder that visitors should receive

Start by identifying the public deliverable. A hand-written site might consist of an index file, a room-information page, a stylesheet and a map. A larger project might include source code, build scripts, dependency files, tests and generated output. Those are not all meant for public delivery. The publishing decision should select the intended output directory, not automatically expose the whole development checkout.

Names such as dist, build and public are conventions, not guarantees. Read the project's instructions and inspect the actual output. A folder called public may contain static inputs that a build combines with other files. A folder called build may be absent until the correct command completes. Before uploading anything, locate the generated entry page and follow its references to the CSS, scripts and images it expects.

Keep a simple manifest for the timetable release. Record the relative path, purpose and, when useful, a checksum of each public file. A checksum summarizes file bytes so you can compare copies. It does not judge whether the date on the timetable is correct, but it can show whether the uploaded file matches the approved one. Content review and transfer verification answer different questions, so use both.

Do not include private keys, environment files, database exports, personal student lists or old backup archives in the public tree. A filename that begins with a dot is not automatically safe from every possible server configuration. A file without a link from the home page can still be requested directly. The simplest protective decision is to keep material that must never be served outside the publishable directory altogether.

Review the release as a collection. The HTML may refer to a new stylesheet name while the upload contains only the old stylesheet. The map may have been moved into another folder without updating its reference. A file-by-file transfer can succeed while the site remains inconsistent. The release manifest gives you a concrete set to compare, and a local HTTP preview shows whether that set works together. MDN's publishing guide introduces the hosting and transfer roles.

Predict the exact asset request before looking for the file

A URL path and a filesystem path are different forms of address. A browser requests a resource within a website. The server's configuration maps that request to a file or another handler. For a straightforward static document root, you can often predict the corresponding file by combining the root with the requested path. However, aliases, rewrites and application routing can change that relationship. Start with the actual mapping used by your site.

Relative references are resolved using the document's base URL. Suppose the home page refers to assets/site.css. From the site root, that naturally points to the assets folder there. If a page in a rooms directory uses the same relative text, the browser may request an assets folder inside rooms instead. To refer to the parent site's assets in that layout, the nested page can use a parent-directory reference. A leading slash instead starts from the origin root, which may be wrong when the whole site is deliberately hosted under a subpath.

Write a small path table before deployment. Include the page URL, the reference written in the HTML, the resulting asset URL and the expected file. Do this for the home page and at least one nested page. The exercise exposes mistakes that are easy to miss when a developer opens only the first page. It also explains why moving an otherwise correct page into a subdirectory can break its styling.

Filename case matters on typical Linux hosting filesystems. A local development filesystem may accept a spelling difference that the Linux destination does not. Treat map.svg and Map.svg as distinct names when preparing a portable release. Consistent lowercase names reduce one common source of mistakes, but consistency matters more than any particular naming style. Check extensions as well: an image saved as one format does not change its actual bytes merely because someone renames its extension.

Spaces and special characters can require URL encoding, and a fragment after a hash identifies a location within a resource rather than a separate file sent to the server. Query parameters are another separate part of a URL. Keep the first project deliberately simple, using short predictable paths, then learn the more complicated cases with an explicit request trace. MDN's link guide explains relative references; Apache's URL-mapping guide explains the server-side mapping.

Explain the home page, directory requests and missing resources

When a visitor requests a directory-style URL, the server may look for a configured index file. This is why requesting the site root often displays index.html without showing that filename in the address bar. The behavior comes from configuration, not from HTML having a special ability to start itself. If the expected index file is absent, the outcome depends on the server's rules, including whether directory listing is permitted.

A directory listing is not a suitable substitute for the intended timetable home page. It can expose filenames and confuse visitors. A controlled information site should have a deliberate result for its root and known directories. Test the room-information directory both with and without its trailing slash and observe any redirect. Relative links can depend on the final base URL, so this is more than a cosmetic detail.

A missing asset should normally produce a meaningful failure such as a 404. Some applications use a fallback that returns an HTML entry page for unfamiliar routes. That can be appropriate for a correctly designed browser-routed application, but applying it indiscriminately to every asset request can return HTML where the browser expects CSS or JavaScript. A success status alone then hides the underlying path problem. Inspect the response content and type.

The response Content-Type tells the browser how the server describes the representation. A stylesheet should have an appropriate CSS media type, an HTML page an HTML type, and an SVG image an SVG type. Check the actual response header when styling or script loading fails. The filename extension helps servers choose a type, but configured mappings and handlers determine the response. See the common media-type reference and Apache MIME module documentation.

For the workshop release, define four expected outcomes: the root displays the timetable, the rooms directory displays directions, the map URL returns the image, and a deliberately nonexistent page returns a missing-resource response. These checks are small enough to repeat after every release. They establish more confidence than a single screenshot of the home page because they exercise the paths the browser and students actually use.

Use the six hosting combinations without memorizing six unrelated procedures

The chapter covers three operating-system families and two web servers. That gives six combinations, but the educational value comes from separating the common work from the package-specific work. Preparing and reviewing the public files is largely the same. The operating system affects installation and service integration. The web server affects configuration syntax and request mapping. Keep these dimensions separate and the matrix becomes much easier to understand.

Learning environmentNginx routeApache routeVerify before applying commands
Ubuntunginx package and serviceapache2 package and serviceRelease, included site directories, enabled configuration and service state
Amazon Linux 2023nginx package and servicehttpd package and serviceRepository release, package paths, active includes and instance network path
CentOS Stream 9nginx package and servicehttpd package and serviceCurrent repository, policy labels, host firewall and active configuration

These are common distribution-package conventions, not a promise that every custom installation uses identical paths. A container, a source build or a third-party package can have a different layout. Identify the installed package and effective configuration before editing. The correct lesson is the one that matches your actual environment, not the one with the most familiar command.

For Nginx, the site is commonly described through a server block, a content root and path-handling directives. For Apache, the corresponding work involves a virtual host, DocumentRoot and applicable directory authorization. The syntax changes, but the questions remain: which requests reach this listener, which site is selected, where are its public files, and can the serving identity read them?

Choose one combination for the first complete exercise. Complete its verification and rollback steps, then repeat the same file set with a second combination. This makes comparison meaningful because the content remains constant while the hosting arrangement changes. Installing both default web-server services on one machine without planning their ports introduces an avoidable conflict. Separate lab hosts or explicitly distinct listeners make the comparison easier to understand.

Read the Ubuntu Nginx guide, Ubuntu Apache guide, Amazon Linux Apache tutorial and Red Hat web-server guidance alongside the relevant lesson. Match the operating-system version rather than applying an old tutorial's assumptions unchanged.

Give the serving process the access it needs

A web server reads files under an operating-system identity. That identity may differ from the account that uploaded the release. A successful upload proves that the uploader could write the destination; it does not prove that the serving process can read it. Check the owner, group and permission bits along the entire path, including parent directories. Directory traversal and file reading are related but different permissions.

The common teaching example of executable directories and readable files should be understood through those operations. A serving process must be able to traverse the directory path and read the content. It usually does not need to modify the static timetable itself. The deployment account can retain controlled write access while the serving identity receives only the access required for delivery. Avoid applying one mode recursively to both files and directories without considering their different roles.

Numeric modes such as 755 for directories and 644 for ordinary public files are common examples, not universal requirements. They grant access to others that may be unnecessary in a more restricted layout. Group-based access, ACLs and operating-system security policy can change the design. Learn what each bit allows before treating a number as a magic repair. Making a directory world-writable can turn a display problem into an integrity problem.

On systems with SELinux enforcement, file labels and policy may affect the web process in addition to traditional mode bits. A copied file can have a context unsuitable for its intended service location. Use the distribution's documented label and policy tools to diagnose the specific denial. Disabling the entire control because a page is forbidden hides the reason and weakens the system. The later CentOS lesson develops this mechanism with the relevant evidence.

Our local preview runs as your ordinary account and serves only the files you create for the exercise. That is useful for understanding paths, but it does not prove that a separately managed Nginx or Apache worker will have the same access. When you move to the server lesson, repeat the request under the real serving arrangement. State this limitation clearly in a lab report: local content verification is complete, and destination service permissions remain a separate check.

Make a release a reviewed collection of files

Uploading directly over a live tree can expose a partially transferred release. A new HTML page may arrive before its stylesheet, or an interrupted transfer may leave only half the images. For a small exercise, you can learn a better pattern by staging the complete candidate separately. Review the candidate, verify its files and then use the site's deployment mechanism to make that release active.

Staging is a place or arrangement for checking a candidate before publication. It is not automatically private simply because its directory is named staging. If it can be reached through a public server mapping, visitors may still access it. Use a loopback preview or another appropriately controlled arrangement for unfinished work. Keep private configuration outside the served tree in both staging and production.

Record the current release before replacing it. Keep the files and configuration needed to restore that release, and write down the verification that will prove recovery. A rollback for a static timetable may be relatively straightforward because it primarily concerns published files. A mixed application can also involve data migrations or backend changes, so a file rollback is not always a complete rollback of the service.

A release-directory approach can reduce the time spent copying into an active location, but it does not make every browser request part of one transaction. A visitor may receive old HTML before a switch and request assets afterward. Content-versioned asset names and retaining the required older assets can help avoid this mismatch. Understand the request sequence before claiming a deployment is entirely atomic from every visitor's point of view.

For our timetable, give each approved candidate a visible release marker in the page footer or a small version file. After publication, request that marker from the intended hostname and compare it with the release record. The marker helps identify which content is being served. It does not replace checking the timetable date, room link, image and stylesheet, but it gives the checks a clear version context.

Connect the public name to the intended release

A public website combines several independently configured pieces. DNS directs the name toward an address or another supported target. The network path permits the intended connection. A web listener accepts it. The site configuration selects the public content. TLS protects and authenticates the connection when HTTPS is used. A mistake in any one piece can prevent the student from receiving the timetable, so test them in a sensible order.

First verify the candidate through a controlled local or staging path. Then verify the named site at its intended destination. A direct request to an IP address may select a default virtual host, which is not necessarily the workshop site. With HTTPS, preserve the intended hostname for certificate verification and server-name selection. Do not bypass certificate validation as the final solution to a name mismatch; determine whether DNS, the certificate or the requested URL is wrong.

Multiple sites can share a web server, but each needs a clear boundary in configuration and content. Keep the workshop release separate from the library release. Check that an update to one site's root or include file does not change the other site's mapping. A generic copy command aimed at a shared parent directory can affect more than the project you meant to publish. Write the destination explicitly and compare its scope with the intended site.

For a public informational site, HTTPS remains useful even when the page does not collect passwords. It protects the delivered timetable and helps the browser verify the site identity. Certificate management and renewal are operating tasks, not one-time decorations. Follow the certificate provider's current requirements for the chosen identifier and deployment. The domain-based lesson shows a common arrangement without implying that every possible TLS deployment has identical requirements.

If you later choose S3 and CloudFront, distinguish an S3 website endpoint from a regular S3 origin. They have different access and HTTPS behavior. Do not copy an EC2 document-root procedure into S3 and expect the same controls to exist. The S3 website-endpoint documentation and CloudFront origin HTTPS documentation explain that separate architecture. Here, keep your focus on the Linux-hosted request path.

Distinguish an old response from a failed upload

A cache stores a response so it can be reused under defined rules. The browser, a shared proxy or a CDN may hold content. This can reduce repeated work, but it also means that replacing a file on the origin does not prove every visitor immediately sees new bytes. When the coordinator sees an old timetable, first determine which release the origin serves and which response the browser actually used.

Cache-Control directives express reuse policy. The names can be misleading to beginners: no-cache allows storage but requires validation before reuse, while no-store asks that the response not be stored. Validators such as ETag and Last-Modified help a client ask whether its stored representation remains usable. A 304 response tells the client to reuse the appropriate stored representation; it is not a missing-resource error. Read the HTTP caching guide for the exact semantics.

Apply the idea to our timetable. The HTML changes when a date changes, so its freshness policy should fit that requirement. A versioned stylesheet can have a different reuse strategy if its URL changes whenever its content changes. The relationship between the HTML reference and the asset version is the important point. Do not overwrite a file advertised as immutable while expecting clients to discover the change immediately under the same URL.

During diagnosis, compare the expected release marker with a direct controlled response and the browser's network evidence. A fresh browser profile is one useful observation, but it does not prove that every shared cache has been bypassed. Likewise, changing a query parameter is not a universal cache invalidation method; cache-key behavior depends on the system. Identify the actual caching layer and use its documented controls.

Keep a distinction between a temporary diagnostic action and the final policy. Disabling all caching may make a particular symptom disappear while unnecessarily slowing normal delivery. Increasing cache lifetime may improve repeated delivery while making timetable corrections less timely. Choose the policy to match the content's update pattern and verify it through response headers and actual requests.

Lab: build and serve a complete miniature release

This exercise uses Bash, Python 3 and curl on your own learning computer. Python's small HTTP server gives us a convenient way to inspect real requests without installing or changing Nginx or Apache. It is a local teaching tool, not the production deployment method. The explicit loopback binding keeps the listener local. Use a different unused high port if the example port is already occupied; never stop an unrelated service to make room.

In terminal A, create a fresh source directory and a separate release directory. The variable holds this attempt's location. Print it and keep the terminal open. The source contains only public practice files, so copying this particular tree is deliberate. A real development project needs the publish-folder review explained earlier.

static_lab=$(mktemp -d /tmp/workshop-static.XXXXXX)
mkdir -p "$static_lab/source/assets" "$static_lab/source/rooms"
mkdir "$static_lab/release-one"
printf 'Practice directory: %s\n' "$static_lab"

Create the home page and the nested room page. Notice their different stylesheet references. The home page starts from the site root, while the room page moves up one directory before reaching the shared assets. The room link points to a directory URL whose index page we provide explicitly.

cat > "$static_lab/source/index.html" <<'HTML'
<!doctype html>
<html lang="en">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Workshop timetable</title>
<link rel="stylesheet" href="assets/site.css">
<main>
  <h1>Workshop timetable</h1>
  <p>Robotics: Monday, 10:00, Room A.</p>
  <p><a href="rooms/">Find the workshop room</a></p>
  <img src="assets/map.svg" alt="Room A is to the right of the entrance" width="320" height="160">
  <p>Release: timetable-r1</p>
</main>
</html>
HTML
cat > "$static_lab/source/rooms/index.html" <<'HTML'
<!doctype html>
<html lang="en">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Workshop room</title>
<link rel="stylesheet" href="../assets/site.css">
<main>
  <h1>Find Room A</h1>
  <p>Enter the workshop building and turn right.</p>
  <p><a href="../">Return to the timetable</a></p>
</main>
</html>
HTML

Add the stylesheet and a small original diagram. The SVG is a text-based image, so the example does not depend on a third-party download. Its filename matches the HTML exactly. The layout allows the image to shrink on a narrow screen, and the alternative text communicates its important direction information without requiring the picture.

cat > "$static_lab/source/assets/site.css" <<'CSS'
body { font: 18px/1.6 system-ui, sans-serif; margin: 0; color: #183348; }
main { max-width: 44rem; margin: auto; padding: 1.5rem; }
h1 { line-height: 1.2; }
a { color: #155f87; }
img { max-width: 100%; height: auto; border: 1px solid #a9bdca; }
CSS
cat > "$static_lab/source/assets/map.svg" <<'SVG'
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 160">
  <rect width="320" height="160" fill="#eff7fa"/>
  <rect x="20" y="50" width="110" height="60" fill="#d6e8f1"/>
  <rect x="190" y="50" width="110" height="60" fill="#d8efdf"/>
  <path d="M140 80h40m-12-10 12 10-12 10" fill="none" stroke="#183348" stroke-width="3"/>
  <text x="75" y="85" text-anchor="middle" font-size="16">Entrance</text>
  <text x="245" y="85" text-anchor="middle" font-size="16">Room A</text>
</svg>
SVG
cp -R "$static_lab/source/." "$static_lab/release-one/"
find "$static_lab/release-one" -type f -print

The listing should show four public files: two HTML pages, one stylesheet and one SVG. The copy uses the source directory's contents so the release root contains the home page directly. If you accidentally create an extra source directory inside the release, the requested root will no longer map to the file you intended. Inspect the tree before starting the preview.

Start the preview in terminal A. It stays in the foreground and prints request logs there. Leave that terminal running while you use terminal B or the browser. The directory option explicitly selects the release, avoiding the mistake of serving whichever working directory happened to be active.

python3 -m http.server 18887 --bind 127.0.0.1 --directory "$static_lab/release-one"

In terminal B, request the home page, nested page, stylesheet, image and a deliberately missing resource. The options prevent use of an environment-configured proxy for these local checks, bound the waiting time and display the response headers. They do not bypass HTTPS verification; these are intentionally local HTTP requests.

curl --noproxy '*' --max-time 5 -i http://127.0.0.1:18887/
curl --noproxy '*' --max-time 5 -i http://127.0.0.1:18887/rooms/
curl --noproxy '*' --max-time 5 -I http://127.0.0.1:18887/assets/site.css
curl --noproxy '*' --max-time 5 -I http://127.0.0.1:18887/assets/map.svg
curl --noproxy '*' --max-time 5 -i http://127.0.0.1:18887/missing.html

Expect successful responses for the four existing resources and a 404 for the last request. Compare the HTML and asset content types. The home-page response must contain the release marker, and the room-page response must contain the directions. These checks prove more than “the server started”: they prove that the selected release contains the expected resources at the tested paths.

Open the same loopback address in a browser. Follow the room link and the return link. Check the page at a narrow window size, confirm the map is visible, and inspect the browser's requests if something is missing. The browser requests the stylesheet and image separately after reading the HTML, while curl does not automatically render HTML or fetch all its references. Understanding that difference explains why a successful curl request to the root is only part of visual verification.

Finish by returning to terminal A and pressing Control-C to stop the foreground preview. Confirm a new request no longer reaches that lab listener. Retain the practice directory if you want to inspect the files. Remove it only after checking its exact path and contents. The Python HTTP-server documentation explains the local server and its production limitations.

Lab: introduce one broken path and recover the approved release

Keep the original release intact and create a second candidate from the reviewed source files. In the second candidate's nested room page, deliberately change the stylesheet reference so it incorrectly points into a rooms/assets directory. Preview that candidate with the same controlled local method. Predict the resulting stylesheet URL before looking at the browser's request record. Then compare the prediction with the observed missing request.

The room page's HTML can still return 200 while its stylesheet returns 404. This is the exact learning result we want. A student who checks only the page status would miss the defect. Restore the correct relative reference, request the page again and confirm the stylesheet request succeeds. Record which file changed and which observation proves the repair, rather than merely writing “fixed CSS.”

Now change the candidate's release marker and timetable time. Review both as a single candidate. Compare its complete file set with the first release and verify the nested link, map and stylesheet. Practice switching the preview to the second release, then stopping it and returning to the first. The visible marker should follow the selected release each time. This rehearsal gives rollback a concrete meaning without modifying a public website.

For a separate case-sensitivity exercise, use a case-sensitive Linux learning filesystem. Change the image reference to different capitalization and observe the missing resource. A case-insensitive local filesystem may not reproduce that failure, so record the environment instead of assuming the exercise behaved identically everywhere. The general lesson is to deploy exact names and verify on the destination's actual filesystem and server arrangement.

Turn a symptom into a narrow next check

If the page cannot be reached at all, begin with the requested destination and listener. A loopback-only preview is not intended to answer from another computer. If the connection succeeds but shows an unexpected page, investigate site selection and the active release root. If the right page appears without styling, inspect the stylesheet's actual URL, response status and type. These symptoms point to different checks; they do not justify the same blanket restart.

If a file exists but is forbidden, inspect access under the real serving identity and relevant policy. If a newly uploaded timetable remains old, compare release markers and caching evidence. If the home page works but a nested page fails, resolve its relative references and index handling. If a link works only after navigating through the home page, consider whether the site uses browser-side routing and whether direct requests have the required server handling.

Keep the failing request in the report. “The map is broken” is less useful than “the room page requests this asset path, receives 404, and the release manifest contains the map under this other path.” The second description identifies both the observed request and the intended file. Another student can reproduce it and propose a targeted correction.

After a repair, repeat the original failing request and one neighboring successful request. A change that fixes the room page but breaks the home page is not complete. Do not broaden changes unnecessarily when the evidence points to one path. Small, verified corrections make the relationship between the problem and the repair easier to understand.

Tasks that demonstrate hosting understanding

  1. Create a release manifest. List the four lab files, their relative paths and their roles. Add a checksum for each using an available tool. Explain which checks detect a changed transfer and which still require a human to review the timetable.
  2. Predict a nested asset URL. Write the browser's requested URL for the room page's stylesheet before making a request. Repeat with the deliberately incorrect reference. Your explanation should connect the page location to the resulting asset location.
  3. Compare two hosting combinations. Choose one Nginx and one Apache environment. Keep the public file set constant. Record the package, service, active configuration, content root and verification request for each. Explain the common responsibilities despite different syntax.
  4. Design a publication boundary. Place public files, source files, private configuration and release backups on a paper directory diagram. Mark the served root and identify which material must remain outside it. Explain why an unlinked backup under that root is still a concern.
  5. Rehearse a rollback. Give two timetable releases different markers and times. Verify the second, identify a deliberate content mistake and return to the first. Record the expected restored marker and the requests that prove the correct version is active.
  6. Investigate an old stylesheet. Explain how you would compare the HTML asset reference, origin response and browser cache evidence. Propose an appropriate versioning approach instead of treating repeated forced refreshes as the deployment process.

Interview questions with reasoning

Can a static website contain JavaScript and interactive controls?

Yes. Static hosting can deliver JavaScript files that run in the browser, such as a timetable filter or menu. The key distinction is where processing occurs. If a control calls an API to save a booking, that operation depends on a backend even if the page files are statically hosted. I would explain both parts rather than classify the whole experience only by whether it contains a button.

Which directory would you publish from a frontend project?

I would identify the reviewed production output from the project's build instructions and inspect its entry page and assets. I would not assume that every directory named public or dist has the same role. The published set should contain the resources visitors need and exclude private configuration, credentials and unrelated development material.

The home page returns 200 but looks unstyled. What comes next?

I would inspect the stylesheet request made by the browser, including its resolved URL, status, content type and body. A wrong nested path can return 404, while an overly broad fallback can return HTML with 200. Then I would compare the request with the release tree and server mapping. Restarting the service is not a substitute for that evidence.

Why can an image work locally and fail on Linux hosting?

One possibility is a filename case difference accepted by the local filesystem but rejected by the destination. Other possibilities include a missing upload, different path base or serving permissions. I would compare the exact HTML reference, requested URL and destination filename before choosing the fix. The environment difference is a clue, not a complete diagnosis.

Does switching a release directory make every visitor's page atomic?

It can make the selected directory change more controlled, but a page involves multiple requests. A visitor may fetch HTML before the switch and assets afterward. Versioned asset references and retaining needed assets help manage that transition. I would describe the guarantees of the actual deployment mechanism rather than promise that every client sees all files from one instant.

What evidence would you collect after publishing a static site?

I would verify the intended hostname and release marker, the main and nested pages, required assets, appropriate response types and a missing-resource case. I would also inspect the mobile display and relevant logs. File-transfer success and process health are useful, but they are narrower than demonstrating that a student can use the published timetable.

Review the complete publishing path

1. A build tool generated the HTML. Must it be served dynamically?

No. Work performed before deployment can produce files that are later delivered statically. Distinguish build-time generation from request-time server processing.

2. A copied folder contains the correct files one level below the configured root. Is that sufficient?

Not for the intended URLs unless the configuration or links account for that extra level. Predict the actual mapping and inspect the release root. Successful copying does not prove correct placement.

3. Does no-cache mean that a response may never be stored?

No. It requires validation before reuse. No-store expresses the storage restriction. Use the directive whose semantics match the content and verify the returned policy.

4. Does the uploader's read access prove the web worker can read the same file?

No. They may use different identities, groups and security contexts. Verify the actual serving arrangement, including parent-directory traversal and applicable operating-system policy.

5. Is an old release backup private because the home page has no link to it?

No. If the server maps a request to that backup under a public root, it may be retrievable directly. Keep material that must not be served outside the public content tree.

Revision cards for a dependable static release

Static delivery
The requested representation is prepared before the request. Browser interaction and separate API calls can coexist with that delivery model.
Publishable output
The reviewed files intended for visitors, identified from the project's actual build and deployment arrangement.
Path prediction
Resolve the reference from its page URL, then compare the resulting request with the server's filesystem mapping.
Release integrity
Verify the whole required file set, including assets and nested pages. A successful transfer of one file is a narrower result.
Access boundary
The serving identity needs appropriate traversal and reading. Public delivery does not require every account to have write access.
Publication evidence
Record the release marker, intended hostname, expected content, assets, display and recovery result so another person can verify the deployment.

You are ready for a specific hosting combination when you can explain where the public files come from, which directory is served and which requests prove that students receive the complete release. Keep the miniature site available while working through the next lesson. Reusing a known file set makes differences in the hosting environment much easier to understand.

Primary references

Practice Tasks

Practice checks run in your browser. They check the answer for this exercise; they do not create resources or connect to your AWS account.

About this scenario

Cape Town Safaris is a tourism business in Cape Town. Thabo Nkosi looks after its IT and cloud work. They count money in ZAR and run their AWS resources in the af-south-1 Region. In the tasks below you do real jobs for them using what this lesson teaches. All names, account IDs, IP addresses and numbers are made up for practice.

0 / 12

Easy Restart a service after a change

Config changes only apply after the service restarts or reloads.

Restart the nginx service.

  1. Find the Linux command that does this job.
  2. Add the options (like -r or -h) the task needs.
  3. Add the file names, folders or users in the right order.
  4. Use sudo if the job changes system files or users. Click Check answer.

Easy Check if a service is running

When a site is down, first check whether the web server process is running.

Show the status of the httpd service.

  1. Find the Linux command that does this job.
  2. Add the options (like -r or -h) the task needs.
  3. Add the file names, folders or users in the right order.
  4. Use sudo if the job changes system files or users. Click Check answer.

Easy Install a package on Ubuntu

Ubuntu uses apt. Package names differ: on Ubuntu Apache is apache2.

Install the apache2 package on Ubuntu without being asked to confirm.

  1. Find the Linux command that does this job.
  2. Add the options (like -r or -h) the task needs.
  3. Add the file names, folders or users in the right order.
  4. Use sudo if the job changes system files or users. Click Check answer.

Easy Install a package on Amazon Linux

dnf is the package manager on Amazon Linux 2023. -y answers yes for you.

Install the httpd package on Amazon Linux 2023 without being asked to confirm.

  1. Find the Linux command that does this job.
  2. Add the options (like -r or -h) the task needs.
  3. Add the file names, folders or users in the right order.
  4. Use sudo if the job changes system files or users. Click Check answer.

Easy Test a website from the server

curl shows whether the web server answers, even before DNS is ready.

Request http://localhost and show only the response headers.

  1. Find the Linux command that does this job.
  2. Add the options (like -r or -h) the task needs.
  3. Add the file names, folders or users in the right order.
  4. Use sudo if the job changes system files or users. Click Check answer.

Easy Download code from GitHub

git clone obtains a working checkout. Identify and review the publishable output before deploying it.

Clone https://github.com/capetownsafari/website.git into the current folder.

  1. Find the Linux command that does this job.
  2. Add the options (like -r or -h) the task needs.
  3. Add the file names, folders or users in the right order.
  4. Use sudo if the job changes system files or users. Click Check answer.

Medium Test the nginx config

A test catches typos before a restart takes your site down.

Check the nginx configuration files for errors.

  1. Find the Linux command that does this job.
  2. Add the options (like -r or -h) the task needs.
  3. Add the file names, folders or users in the right order.
  4. Use sudo if the job changes system files or users. Click Check answer.

Medium Start a service now and at boot

enable makes it start after reboot; --now also starts it right away.

Enable the nginx service and start it immediately, in one command.

  1. Find the Linux command that does this job.
  2. Add the options (like -r or -h) the task needs.
  3. Add the file names, folders or users in the right order.
  4. Use sudo if the job changes system files or users. Click Check answer.

Medium Open port 80 to the world

This worksheet practices a public HTTP listener. Verify the intended protocol, port, routes and running service; an HTTPS-only design uses its own listener rule.

Allow inbound TCP port 80 from 0.0.0.0/0 on security group sg-022b36ab6b244c3b2.

  1. Read the task and decide which AWS service it is about.
  2. Write aws, then the service name, then the operation (the action word).
  3. Add each needed flag (--name) followed by its value from the task.
  4. Flags can be in any order. Click Check answer.

Medium CloudFormation: web security group

This worksheet describes an HTTPS listener rule. Network access, TLS and application authorization are separate parts of the design.

Template with an AWS::EC2::SecurityGroup that allows TCP 443 from 0.0.0.0/0. Add a GroupDescription.

  1. Start from the top-level keys the task names.
  2. Indent child keys with 2 spaces (no tabs).
  3. Fill in each property with the value from the task.
  4. Click Check answer. Key order does not matter.

Medium Create a security group

A security group is the firewall around your instance.

Create a security group named capetownsafari-web-sg with description "Web servers" in vpc-0f3cafcf24deadbee.

  1. Read the task and decide which AWS service it is about.
  2. Write aws, then the service name, then the operation (the action word).
  3. Add each needed flag (--name) followed by its value from the task.
  4. Flags can be in any order. Click Check answer.

Hard Enable an nginx site on Ubuntu

On Ubuntu, a site is enabled by a symbolic link from sites-available to sites-enabled.

Create a symbolic link to /etc/nginx/sites-available/capetownsafari inside /etc/nginx/sites-enabled/.

  1. Find the Linux command that does this job.
  2. Add the options (like -r or -h) the task needs.
  3. Add the file names, folders or users in the right order.
  4. Use sudo if the job changes system files or users. Click Check answer.