# Deployment — Noble Collectable

How to install, configure, and deploy the store on cPanel hosting.

---

## Pre-Deployment Checklist

- [ ] cPanel hosting account active with PHP 8.0+ and MySQL 5.7+
- [ ] Domain/subdomain pointing to the cPanel account
- [ ] SSL certificate provisioned (via AutoSSL or Let's Encrypt)
- [ ] Backup plan in place (daily cPanel backups enabled)
- [ ] Payment provider account created (Stripe, PayPal, etc.)
- [ ] Logo and brand assets finalized

---

## Initial Setup (One-Time)

### Option A: cPanel One-Click Installer (Easiest)

1. **Log into cPanel**
2. **Find "WordPress" or "Softaculous"** section
3. **Click "Install"** and follow the wizard:
   - Choose domain/subdomain
   - Set admin username & password (keep secure!)
   - Email for notifications
   - Site title & tagline
4. **Installation completes** in 2–5 minutes
5. **Admin URL:** `your-domain.com/wp-admin`

### Option B: Manual Installation (If one-click unavailable)

1. **Download WordPress:**
   - Go to [wordpress.org](https://wordpress.org/download/)
   - Download the latest `.tar.gz` file

2. **Upload via FTP:**
   - Use FileZilla or cPanel's **File Manager**
   - Extract WordPress files to `public_html/` (or a subfolder if not root domain)

3. **Create Database:**
   - cPanel → **MySQL Databases**
   - Create new database (e.g., `noblecoll_db`)
   - Create user (e.g., `noblecoll_user`) with password
   - Grant all privileges to user on database

4. **Run WordPress Installer:**
   - Visit `your-domain.com/wp-admin/install.php`
   - Enter database name, user, password
   - Follow on-screen setup

---

## Post-Installation: Initial Configuration

### 1. Secure the Admin

```
Dashboard → Settings → General
- Site Title: "Noble Collectable"
- Tagline: (e.g., "Graded & Authenticated Football Cards")
- Site Address: https://your-domain.com (use HTTPS!)
```

### 2. Install Required Plugins

- **WooCommerce** — Core e-commerce. Install via Dashboard → Plugins → Add New → search "WooCommerce" → Install & Activate
- **Polylang Free** — Bilingual support. Search "Polylang" → Install & Activate
- **Stripe for WooCommerce** (or PayPal) — Payment gateway. Install via Plugins
- **WP Smush** — Image optimization. Install to auto-compress product photos

**Do not install unnecessary plugins** — each one adds overhead.

### 3. Configure WooCommerce

- Dashboard → **WooCommerce** → **Settings**
  - **General:** Shop name, store address (for invoices/shipping labels)
  - **Products:** Enable reviews (optional), set default image size
  - **Shipping:** Add shipping zones & rates (e.g., "EU Standard 5-7 days: €10", "EU Express 1-2 days: €20")
  - **Tax:** Set up tax rules if needed (EU VAT, US sales tax, etc.)

### 4. Configure Polylang

- Dashboard → **Languages** → **Settings**
  - Add French & English languages
  - Choose URL structure (`/fr/` prefix or domain-based)
  - Translate strings (navigation, buttons, etc.) as needed

### 5. Set Up Payment Gateway

**Stripe Example:**
- Create [Stripe account](https://stripe.com) (free)
- Get API keys (live & test)
- Dashboard → **Plugins** → Install "Stripe for WooCommerce"
- **WooCommerce** → **Settings** → **Payments** → **Stripe** → Paste API keys
- Save & test with a test card

**PayPal Example:**
- Create [PayPal account](https://paypal.com) (Business account)
- Get API credentials
- Dashboard → **Plugins** → Install "PayPal for WooCommerce"
- **WooCommerce** → **Settings** → **Payments** → **PayPal** → Paste credentials

### 6. Upload Theme Assets

- **Logo:** Brand team will provide SVG/PNG files
- Upload to **Media Library** → use in theme
- **Images:** Set up folder structure in cPanel for product photos

---

## Ongoing Maintenance

### Daily
- (Automated) Check WordPress for updates

### Weekly
- Monitor **Orders** page for new orders
- Check **Products** for stock levels

### Monthly
- Install WordPress core & plugin updates (Dashboard → Updates)
- Review cPanel **Backup** status
- Review sales reports (WooCommerce → Reports)

### Quarterly
- Security audit: Check user list, disable old admin accounts
- Prune old spam comments if enabled
- Review backup retention (ensure backups are stored off-site if possible)

---

## Backups & Disaster Recovery

### Automated Backups (cPanel)

1. cPanel → **Backup** → **Backup Wizard**
2. Enable **Automatic Daily Backups**
3. Store backups to remote server or download regularly to your computer
4. **Retention:** Keep at least 4 weeks of backups

### Manual Backup (If needed)

1. **Database export:**
   - cPanel → **phpMyAdmin** → Select database → **Export** → Download SQL file

2. **Files export:**
   - cPanel → **File Manager** → Select `public_html/` → **Compress** → **Download**

### Restore from Backup

1. If catastrophic failure:
   - Contact cPanel support to restore from automated backup, OR
   - Upload backed-up files & database manually

---

## Moving to a Different Host

### Export from Current Host

1. **Export database:**
   - cPanel → **phpMyAdmin** → Your database → **Export** → Save SQL file

2. **Download files:**
   - FTP or cPanel File Manager → Download `/wp-content/` and `/wp-includes/` folders (keep `/wp-content/` especially)

### Deploy to New Host

1. **Create new database** on new host
2. **Create new cPanel/hosting account** with new domain
3. **Upload WordPress files** to new hosting's `public_html/`
4. **Import database:** cPanel → **phpMyAdmin** → Create database → **Import** → Select SQL file
5. **Update WordPress config:**
   - Edit `wp-config.php` → Update database name, user, password
6. **Update site URLs (if domain changed):**
   - New host's WordPress → **Settings** → **General** → Update "Site Address"
   - Or use [Search & Replace plugin](https://wordpress.org/plugins/better-search-replace/) to update internal URLs in database
7. **Test:** Visit new domain, log in, verify products and orders show correctly

---

## Security Best Practices

1. **HTTPS Only:**
   - cPanel → **AutoSSL** or **Let's Encrypt** → Ensure certificate is active
   - WordPress → **Settings** → Force HTTPS in Site Address

2. **Strong Admin Password:**
   - Change default admin password immediately
   - Use 16+ characters with mixed case, numbers, special chars

3. **Limit Login Attempts:**
   - Install plugin: "Limit Login Attempts Reloaded"
   - Prevents brute-force attacks

4. **Regular Updates:**
   - WordPress core updates (critical security fixes)
   - Plugin updates (especially WooCommerce, Stripe, Polylang)

5. **Remove Unused Plugins & Themes:**
   - Only activate what you use
   - Delete old themes/plugins that are inactive

6. **Firewall (Optional):**
   - Consider Cloudflare free tier for DDoS protection
   - cPanel may include ModSecurity firewall — enable it

---

## Troubleshooting Deployment

| Issue | Cause | Solution |
|-------|-------|----------|
| **Blank white screen** | PHP error or memory limit | Check cPanel error logs; increase `memory_limit` in `.htaccess` |
| **Admin login doesn't work** | Database not accessible | Verify database credentials in `wp-config.php` |
| **Images not uploading** | File permissions or storage limit | cPanel → File Manager → `wp-content/uploads/` → Permissions 755 |
| **Slow site** | Too many plugins or large images | Disable unused plugins; optimize images via WP Smush |
| **Payment gateway not working** | API keys incorrect or not saved | Re-check Stripe/PayPal credentials in WooCommerce Settings |
| **Site not loading over HTTPS** | SSL certificate issue | cPanel → AutoSSL → Generate/renew cert, or contact cPanel support |

---

## Monitoring & Analytics

- **WordPress:** Dashboard → Stats (if Jetpack installed)
- **WooCommerce:** Dashboard → Reports (sales, revenue, products)
- **Stripe/PayPal:** Payment provider's dashboard for payouts
- **cPanel:** Monitor bandwidth and disk usage monthly

---

**Contact:** For issues during deployment or maintenance, contact Yousha Rizvi or your hosting provider's support.

**Next:** See [`ROADMAP.md`](./ROADMAP.md) for timeline of setup phases.
