Chapter 7: Static Website Hosting (3 OSes × 2 Web Servers)
Interview Questions
- Q1. What is a document root?
- The directory from which the web server serves files; the URL path is appended to it to find the file.
- Q2. How does one server host multiple websites on the same IP and port?
- Name-based virtual hosting: the web server reads the HTTP
Hostheader and chooses the matchingserver_name(Nginx) orServerName(Apache) block. - Q3. A static site returns 403 Forbidden. How do you troubleshoot?
- Check an index file exists, permissions along the whole path (
namei -l), ownership, SELinux labels (ls -Z,restorecon), and theRequire all granted/rootdirectives; read the error log. - Q4. What is the difference between
sites-availableandsites-enabledon Ubuntu? sites-availableholds all site configs; only those symlinked intosites-enabled(vialn -sora2ensite) are loaded.- Q5. How do you upload a local folder to an EC2 instance?
scp -i key.pem -r ./site user@IP:~/,rsync -avz,git cloneon the server, or SFTP clients like WinSCP/MobaXterm.- Q6. How do you add HTTPS to a site on EC2?
- Point a domain to the Elastic IP, open port 443, install certbot and run
certbot --nginx -d domain(or--apache); it installs a Let's Encrypt certificate and auto-renewal.