Ravindra BagaleCourses & study guides

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

Practice Questions and Lab Exercises

  1. What is a static website? Give three examples.
  2. Write the document root, site config location and web-server user for all six combinations.
  3. Why do we run restorecon on CentOS? What happens to SELinux labels when files are moved with mv?
  4. Write an Nginx server block and an Apache virtual host for college.example.com with root /var/www/college.
  5. A site gives 403 Forbidden. List four possible causes and how you would check each.
  6. Lab: Host your personal portfolio on Ubuntu + Nginx using git clone.
  7. Lab: Host the same site on CentOS Stream 9 + Apache. Deliberately mv a file from your home folder into the site and observe the 403; fix it with restorecon.
  8. Lab: Host two sites on one server using name-based virtual hosts and test with curl -H "Host: ...".

Quick Revision

  • Static site = files only. URL path maps to files under the document root.
  • Steps: create/upload files → copy to /var/www/mysite → 755 dirs / 644 files → vhost/server block → test config → reload → browse.
  • Nginx: conf.d/*.conf (AL/CentOS) or sites-available + symlink (Ubuntu). Apache: conf.d/*.conf (AL/CentOS) or a2ensite (Ubuntu).
  • CentOS extras: restorecon -Rv, firewalld --add-service=http.
  • Troubleshoot: curl -I localhost, ss -tlnp, error logs, security group.
  • Next: Chapter 8 explains every config line (root, ports, vhosts); Chapter 9 gives the site a real domain.