Chapter 6: Web Servers — Nginx and Apache
Practice Questions and Lab Exercises
- What are the three main jobs of a web server?
- Give six differences between Nginx and Apache. When would you choose each?
- Write the package name, service name, config path and default web root of Apache on Ubuntu and on CentOS Stream 9.
- What is
.htaccess? Why doesn't Nginx support it? - What do HTTP status codes 403, 404 and 502 mean? Give one cause of each.
- What is SELinux? Which command fixes file labels after copying website files?
- Lab: Install Nginx on Amazon Linux 2023, verify with
curl -I, then stop Nginx, install Apache and verify it serves a custom page. - Lab: On Ubuntu, list the files in
sites-availableandsites-enabledand explain the symlink. - Lab: On CentOS Stream 9, check
getenforceand 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
httpdon AL2023/CentOS,apache2on 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 withnginx -t/apachectl configtest.- CentOS: firewalld
--add-service=http, SELinuxrestorecon,setsebool -P httpd_can_network_connect 1.