# Master Ecommerce BD — cPanel Installation Guide

CodeCanyon-style **web installer** — ZIP upload করার পর browser থেকে fully automated setup।

---

## Quick steps (cPanel)

1. **MySQL database** তৈরি করুন (cPanel → MySQL® Databases)
2. **ZIP upload** করুন `public_html/` (বা subdomain folder)
3. Extract করুন — document root **`public/`** folder-এ point করুন
4. Browser-এ যান: **`https://yourdomain.com/install`**
   - অথবা: `https://yourdomain.com/install/` (redirect folder)
5. Requirements সব **✓** হলে form fill করুন → **Install Now**
6. Success page → **Admin Panel** এ login

---

## Install form fields

| Field | Maps to |
|-------|---------|
| License Key | `.env` → `LICENSE_KEY` |
| Store Name | `.env` → `APP_NAME` + General Settings |
| Site URL | `.env` → `APP_URL`, `REVERB_HOST`, mail placeholders |
| Database | `.env` → `DB_HOST`, `DB_PORT`, `DB_DATABASE`, `DB_USERNAME`, `DB_PASSWORD` |
| Admin | User account + General Settings (name, email, phone) |
| Optional `.sql` | Auto import after migrate (demo seed skipped) |

**Test Database Connection** button দিয়ে আগে verify করুন। Submit করলে wizard **নিজেই `.env` লিখে** key generate, migrate, seed/import, admin, cache, lock — সব চালায়।

---

## Server requirements (auto-checked)

- PHP **8.2+**
- Extensions: bcmath, curl, dom, fileinfo, gd, mbstring, openssl, pdo_mysql, xml, …
- Writable: `storage/`, `bootstrap/cache/` (chmod **775** recommended)
- Full ZIP with **`vendor/`** folder

Permission fix (Terminal):

```bash
bash fix-permissions.sh
```

---

## What installer runs automatically

1. Write `.env` from form (production defaults, `APP_INSTALLED=false` until finish)
2. Reload environment + clear config cache (DB credentials apply immediately)
3. `php artisan key:generate`
4. `php artisan migrate --force`
5. Seed roles (required)
6. **If `.sql` attached:** import SQL → demo seed skipped · **If not:** full `DatabaseSeeder`
7. Create your admin account + store settings
8. `storage:link` + config/route/view cache
9. Set `APP_INSTALLED=true` + create `storage/app/install.lock`

### Optional SQL import

| Attach `.sql`? | What happens |
|----------------|--------------|
| **No** | Empty DB → migrate + roles + demo seed (categories, settings, etc.) |
| **Yes** | Migrate + roles → **your SQL imported** → demo seed **skipped** |

**Best for `.sql`:** data-only dump (INSERT) after tables exist — e.g. old store backup, phpMyAdmin export without `CREATE TABLE`.

**Avoid:** full dump with `CREATE TABLE` on fresh install (migrate already created tables → conflict).

Max file size: **50 MB** (see `config/cpanel-deploy.php` → `sql_import.max_kb`).

---

## After installation

- Installer **auto-disabled** — `/install` redirect to admin login
- Optional: delete `public/install/` folder (শুধু redirect, required নয়)
- Cron (every minute):

```bash
cd /home/user/public_html && php artisan schedule:run >> /dev/null 2>&1
```

- Admin: `https://yourdomain.com/admin/login`

---

## Updates (existing store)

নতুন version ZIP দিলে **install নয়**, **upgrade** ব্যবহার করুন:

1. `.env` backup
2. ZIP extract (`.env` overwrite করবেন না)
3. `.env`-এ `APP_UPGRADE=true`
4. Visit **`/upgrade`** → Run Upgrade Now
5. `APP_UPGRADE=false` set করুন

বিস্তারিত: `CPANEL-UPDATE-GUIDE.md`

---

## Troubleshooting

| Problem | Fix |
|---------|-----|
| Red ✗ on permissions | `bash fix-permissions.sh` or cPanel chmod 775 |
| Database connection fail | Host `localhost`, correct DB user attached to DB |
| 500 after install | Check `storage/logs/laravel.log` |
| Still shows /install on live site | Delete `storage/app/install.lock` only if reinstall needed |
| Blank page | Document root must be `public/` |

---

## Developer build new release

```powershell
cd e:\projects\ecomnew
.\scripts\build-cpanel-release.ps1
```

Upload: `release/cpanel-upload.zip`

---

**IT Square BD** · Master Ecommerce BD Mother Script
