Ravindra BagaleCourses & study guides

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 Host header and chooses the matching server_name (Nginx) or ServerName (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 the Require all granted / root directives; read the error log.
Q4. What is the difference between sites-available and sites-enabled on Ubuntu?
sites-available holds all site configs; only those symlinked into sites-enabled (via ln -s or a2ensite) 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 clone on 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.