Ravindra BagaleCourses & study guides

Chapter 6: Web Servers — Nginx and Apache

Practice Questions and Lab Exercises

  1. What are the three main jobs of a web server?
  2. Give six differences between Nginx and Apache. When would you choose each?
  3. Write the package name, service name, config path and default web root of Apache on Ubuntu and on CentOS Stream 9.
  4. What is .htaccess? Why doesn't Nginx support it?
  5. What do HTTP status codes 403, 404 and 502 mean? Give one cause of each.
  6. What is SELinux? Which command fixes file labels after copying website files?
  7. Lab: Install Nginx on Amazon Linux 2023, verify with curl -I, then stop Nginx, install Apache and verify it serves a custom page.
  8. Lab: On Ubuntu, list the files in sites-available and sites-enabled and explain the symlink.
  9. Lab: On CentOS Stream 9, check getenforce and the firewalld status and open HTTP if needed.

Quick Revision

  • Web server = serves static files + reverse-proxies dynamic requests + TLS/logging/vhosts.
  • Nginx = event-driven, great reverse proxy; Apache = modules + .htaccess.
  • Apache is httpd on AL2023/CentOS, apache2 on Ubuntu.
  • Nginx root: /usr/share/nginx/html (AL2023/CentOS), /var/www/html (Ubuntu). Apache root: /var/www/html.
  • sudo service <name> start + sudo systemctl enable <name>; test with nginx -t / apachectl configtest.
  • CentOS: firewalld --add-service=http, SELinux restorecon, setsebool -P httpd_can_network_connect 1.