Chapter 7: Static Website Hosting (3 OSes × 2 Web Servers)
Practice Questions and Lab Exercises
- What is a static website? Give three examples.
- Write the document root, site config location and web-server user for all six combinations.
- Why do we run
restoreconon CentOS? What happens to SELinux labels when files are moved withmv? - Write an Nginx server block and an Apache virtual host for
college.example.comwith root/var/www/college. - A site gives 403 Forbidden. List four possible causes and how you would check each.
- Lab: Host your personal portfolio on Ubuntu + Nginx using
git clone. - Lab: Host the same site on CentOS Stream 9 + Apache. Deliberately
mva file from your home folder into the site and observe the 403; fix it withrestorecon. - 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→755dirs /644files → vhost/server block → test config → reload → browse. - Nginx:
conf.d/*.conf(AL/CentOS) orsites-available+ symlink (Ubuntu). Apache:conf.d/*.conf(AL/CentOS) ora2ensite(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.