🌍 21. Deployment (PHP)

🟢 1. Hosting Types (Foundation)

🔹 Shared Hosting

  • What is shared hosting?
  • Pros:
    • Cheap (₹50–₹300/month)
    • Easy setup (cPanel)
  • Cons:
    • Limited performance
    • No root access

🔹 VPS Hosting

  • What is VPS?
  • Pros:
    • Full control (root access)
    • Better performance
  • Cons:
    • Requires server knowledge

🔹 Dedicated Server (Brief)

  • High traffic websites
  • Full hardware control

🔹 Cloud Hosting (Bonus)

  • AWS, DigitalOcean, Azure
  • Scalable apps

🟢 2. Domain Setup

🔹 Buying Domain

  • Platforms:
    • GoDaddy
    • Namecheap
    • Hostinger

🔹 DNS Basics

  • Nameservers
  • A Record
  • CNAME
  • TTL

🔹 Connecting Domain to Hosting

  • Point domain to hosting:
    • Update Nameservers
      OR
    • Add A Record (IP)

🔹 Subdomain Setup

  • blog.example.com
  • api.example.com

🟢 3. cPanel Basics (Most Important for Beginners)

🔹 File Management

  • File Manager
  • Upload ZIP & Extract
  • public_html folder

🔹 Database Setup

  • MySQL Database
  • Create DB + User
  • Assign privileges

🔹 phpMyAdmin

  • Import SQL file
  • Export database backup

🔹 Email Setup

🔹 SSL Certificate (HTTPS)

  • Install free SSL (Let’s Encrypt)
  • Force HTTPS

🟢 4. Deploying PHP Project (Shared Hosting)

🔹 Steps:

  1. Zip your project
  2. Upload to public_html
  3. Extract files
  4. Configure:
    • .env or config.php
    • Database credentials
  5. Import database via phpMyAdmin
  6. Test website

🟢 5. Git Deployment (Professional Way)

🔹 Git Basics

  • git init
  • git add .
  • git commit
  • git push

🔹 GitHub Setup

  • Create repository
  • Push project

🔹 Deploy via Git (cPanel)

  • Use Git Version Control feature
  • Clone repo to server

🔹 Auto Deployment

  • GitHub Webhooks
  • Auto pull on push

🟢 6. VPS Deployment (Advanced)

🔹 Server Setup

  • Install:
    • Apache / Nginx
    • PHP
    • MySQL

🔹 Basic Commands

sudo apt update
sudo apt install apache2 php mysql-server

🔹 Project Setup

  • Upload via:
    • Git clone
    • FTP (FileZilla)

🔹 Permissions

chmod -R 755 folder

🟢 7. Environment Configuration

🔹 Config Files

  • .env usage
  • Hide sensitive data

🔹 Production vs Local

  • Debug mode OFF
  • Error reporting OFF

🟢 8. Security Basics (VERY IMPORTANT)

  • Disable directory listing
  • Use .htaccess
  • Protect admin panel
  • Sanitize inputs
  • Backup regularly

🟢 9. Performance Optimization

  • Enable caching
  • Use CDN (Cloudflare)
  • Optimize images
  • Minify CSS/JS

🟢 10. Backup & Monitoring

  • Daily backups
  • Database backup
  • Uptime monitoring tools

🟢 11. Real Deployment Project (Practical)

Students should deploy:

  • ✅ Blog system
  • ✅ Portfolio website
  • ✅ API project

🎯 Final Outcome

After completing this module, students can:

  • Buy domain & hosting
  • Deploy PHP projects live
  • Use Git for deployment
  • Manage cPanel professionally
  • Handle real production websites