Unit 14 ยท Hosting and Publishing a Web Site

14.3Publishing a Web Site

On this page
  1. A. Prepare the site for production
  2. B. Set up the server side (shared hosting with cPanel)
  3. C. Upload the files
  4. D. Test the live site
  5. E. After launch

A. Prepare the site for production

  1. Test everything locally (all links, forms, cart, admin, mobile view).
  2. Move configuration into one place (config/db.php or environment variables) so you only change it once.
  3. Turn off error display (display_errors = 0) and log errors to a file instead.
  4. Remove test pages, sample data, phpinfo() files and debug code.
  5. Optimise: compress images, minify CSS and JavaScript (optional), use relative or correct absolute paths.
  6. Export the database from phpMyAdmin (Export, SQL format).
  7. Check case-sensitivity: Linux servers treat Logo.png and logo.png as different files (Windows does not).

B. Set up the server side (shared hosting with cPanel)

  1. Log in to cPanel.
  2. MySQL Databases: create a database, create a database user with a strong password, and add the user to the database with all privileges. (Hosts add prefixes such as acct_shop.)
  3. phpMyAdmin: select the new database and Import your .sql file.
  4. Edit config/db.php on the server with the new host (usually localhost), database name, username and password.
  5. Select the PHP version (Select PHP Version or MultiPHP Manager) and enable needed extensions (pdo_mysql, curl, mbstring, gd).

C. Upload the files

MethodHow
cPanel File ManagerUpload a .zip to public_html, then Extract (easiest for beginners)
FTP / SFTPUse FileZilla: host, username, password, port 21 (FTP) or 22 (SFTP, preferred); drag files to public_html
Git deploymentgit push to a repository; the host pulls or an action deploys (professional workflow)
SSH and rsyncFor VPS servers

D. Test the live site

Visit the site and test every feature: registration, login, cart, checkout with sandbox payment, email sending, file uploads, mobile layout. Check the host's error log if something fails (500 errors are usually a wrong database password, a missing PHP extension, a wrong path or a PHP version mismatch).

E. After launch