Unit 14 · Hosting and Publishing a Web Site

14.5Review Questions

  1. Difference between a domain name and web hosting?
  2. Explain the steps of a DNS lookup. What does TTL control?
  3. Which DNS record would you create for (a) pointing myshop.lk to an IP address, (b) making www an alias, (c) setting up email?
  4. Why can a PHP and MySQL site not be hosted on GitHub Pages?
  5. List the steps to move a local PHP/MySQL site to cPanel hosting.
  6. What does SSL/TLS protect, and what is a Certificate Authority?
  7. What is mixed content and how do you fix it?
Show answers
  1. A domain name (for example myshop.lk) is the address people type; it is rented yearly from a registrar. Web hosting is the server space (computer, storage, PHP, database) where the site's files actually live. DNS records connect the domain to the host's IP address.

    1. The browser checks its own cache, then the OS cache.
    2. It asks the recursive resolver (usually the ISP's).
    3. The resolver asks a root server, which points to the TLD server (.lk).
    4. The TLD server points to the domain's authoritative name server.
    5. The authoritative server returns the IP address; the resolver caches it and gives it to the browser.

    TTL (time to live) is the number of seconds a DNS answer may be cached; a low TTL makes changes spread faster.

  2. (a) an A record (AAAA for IPv6); (b) a CNAME record (www → myshop.lk); (c) an MX record (plus TXT records such as SPF for email authentication).

  3. GitHub Pages hosts only static files (HTML, CSS, JavaScript). It cannot run PHP on the server and has no MySQL database, so the site needs a host with PHP and MySQL, such as shared cPanel hosting or a VPS.

    1. Test locally, move settings to config/db.php, turn off display_errors, remove test files.
    2. Export the database from phpMyAdmin (.sql).
    3. In cPanel, create a database and user, and add the user to the database with privileges.
    4. Import the .sql file in phpMyAdmin.
    5. Upload the files to public_html (File Manager zip and extract, or FTP/SFTP).
    6. Update config/db.php with the new database details; select the PHP version and extensions.
    7. Set permissions (folders 755, files 644), enable SSL, and test every feature.
  4. SSL/TLS encrypts the connection between the browser and the server, protecting confidentiality (passwords and card data cannot be read), integrity (data cannot be changed in transit) and authentication (you are talking to the real site). A Certificate Authority (for example Let's Encrypt) is a trusted organisation that checks domain ownership and digitally signs the certificate, which browsers trust.

  5. Mixed content is when an HTTPS page loads resources (images, scripts, CSS) over plain HTTP; browsers block or warn about it and the padlock is lost. Fix it by loading every resource over HTTPS (or with relative URLs), updating hard-coded http:// links in code and the database, and redirecting HTTP to HTTPS.