# NFC BD — cPanel-e host korar niyom

Ek domain-e sob cholbe:
- `https://apnar-domain.com` → app (customer, merchant, field officer, admin)
- `https://apnar-domain.com/api/v1` → Laravel API (web + mobile app)

## Ei zip-e ki ache

```
nfcbd-cpanel/
├── public_html/        → cPanel-er public_html-er BHETORE jabe (React app + .htaccess + laravel.php + chhobi)
├── nfcbd-api/          → public_html-er BAIRE, home folder-e jabe (Laravel + .env)
└── database/
    ├── nfcbd-cpanel-clean.sql   → live-er jonno: service, 3 package + rate, banner, shudhu admin
    └── nfcbd-cpanel-demo.sql    → test-er jonno: upore-r sob + 33 shop, 24 customer, card, history
```

Server-e folder emon hobe:
```
/home/CPANEL_USER/
├── nfcbd-api/        ← Laravel (code, vendor, .env) — browser theke dekha jay na
└── public_html/      ← index.html, assets/, brand/, storage/, .htaccess, laravel.php
```

## Ja lagbe
- cPanel hosting, **PHP 8.2 ba notun**, MySQL/MariaDB
- Domain-ta hosting-e pointed
- Apnar PC-r `C:\xampp2026\htdocs\nfcbd-api\vendor` folder (`composer install` kore je folder banche)

---

## Dhap 1 — PHP version
cPanel → **MultiPHP Manager** (ba **Select PHP Version**) → domain-er jonno **PHP 8.2** ba **8.3** select korun.
Extension gulo chalu thakte hobe: `pdo_mysql`, `mbstring`, `openssl`, `fileinfo`, `curl`, `tokenizer`, `xml`, `ctype`, `zip`
(prai sob hosting-e age thekei chalu thake).

## Dhap 2 — Database
1. cPanel → **MySQL® Databases**
   - **Create New Database**: `nfcbd` likhun → nam hobe `cpuser_nfcbd` (cpuser = apnar cPanel username)
   - **Add New User**: `nfcbd` + shokto password → `cpuser_nfcbd`
   - **Add User To Database** → user ar database select → **ALL PRIVILEGES** → Make Changes
2. cPanel → **phpMyAdmin** → bame `cpuser_nfcbd` database-e click → upore **Import** →
   `database/nfcbd-cpanel-clean.sql` (live) **othoba** `nfcbd-cpanel-demo.sql` (test) → **Go**

## Dhap 3 — Laravel (nfcbd-api) upload
1. Apnar PC-te: `C:\xampp2026\htdocs\nfcbd-api\vendor` folder-ta copy kore ei zip-er `nfcbd-api` folder-er bhetore paste korun.
2. `nfcbd-api` folder-ta zip korun → `nfcbd-api.zip`
3. cPanel → **File Manager** → **home folder** (`/home/cpuser`, public_html-er BAIRE) → **Upload** → `nfcbd-api.zip` → upload shesh hole file-e right click → **Extract**.
   - Shesh-e `/home/cpuser/nfcbd-api/vendor/autoload.php` thakte hobe.
4. File Manager-e upore dane **Settings** → **Show Hidden Files (dotfiles)** tick din.
5. `/home/cpuser/nfcbd-api/.env` → right click → **Edit** → `<-- CHANGE` lekha line gulo bodlan:
   - `APP_URL`, `FRONTEND_URL`, `CORS_ALLOWED_ORIGINS` → `https://apnar-domain.com`
   - `DB_DATABASE`, `DB_USERNAME`, `DB_PASSWORD` → Dhap 2-er nam ar password
     (password-e `#` ba space thakle `"..."` er moddhe likhun)
   - `SMS_API_KEY`, `SMS_SENDER_ID` → Automas-er key
   - Save.

> Server-e Terminal ar composer thakle 1–2 dhap-er bodle: `cd ~/nfcbd-api && composer install --no-dev --optimize-autoloader`

## Dhap 4 — App (public_html) upload
1. `public_html` folder-er **bhetorer sob kichu** zip korun (folder-ta na, bhetorer file gulo).
2. File Manager → `public_html` → purono `index.html`/default page thakle muche din → **Upload** → zip → **Extract**.
3. `public_html`-e ekhon thakbe: `index.html`, `assets/`, `brand/`, `storage/`, `manifest.webmanifest`, `laravel.php`, `.htaccess`.

## Dhap 5 — SSL (https)
cPanel → **SSL/TLS Status** → domain select → **Run AutoSSL**. https chalu hole `public_html/.htaccess`-e
`# RewriteCond %{HTTPS} off` ar `# RewriteRule ^ https://...` line duitar shuru-r `#` muche din (sob http → https).

## Dhap 6 — Check
1. `https://apnar-domain.com/api/v1/home` → JSON dekhabe (`{"banners":[...`)
2. `https://apnar-domain.com` → app khulbe
3. Login: **01700000000 / admin123** → `/admin` → **ইউজার** → nijer (Super Admin) line-e ✏️ → notun password → সেভ.
   **Eta prothom-ei korben.**
4. Admin panel theke shop, field officer, package-er dam/rate thik korun.

---

## Shomossa hole

| Ki dekhay | Ki korben |
|---|---|
| `/api/v1/home`-e "Laravel folder or vendor/ not found" | `nfcbd-api` folder home-e ache kina ar bhetore `vendor` ache kina dekhun. Onno jaygay rakhle `public_html/laravel.php`-er `$laravel = ...` line bodlan. |
| 500 Server Error | `nfcbd-api/storage/logs/` folder-er shesh log file khulun — error lekha thakbe. Prai-i `.env`-er DB nam/password bhul. |
| Login hoy, kintu porer page-e abar login chay | Hosting Authorization header atkacche. `public_html/.htaccess` upload hoyeche kina dekhun (hidden file). |
| Chhobi dekhay na | `public_html/storage/plans/` e chhobi ache kina, ar `.env`-er `APP_URL` thik kina dekhun. |
| `/packages` ba `/admin` refresh korle 404 | `.htaccess` public_html-e nei — Show Hidden Files diye dekhun. |
| Addon domain / subdomain-e rakhte chan | Tar folder (jemon `/home/cpuser/nfcbd.com`) public_html-er jaygay use korun; `laravel.php`-e `$laravel = __DIR__ . '/../nfcbd-api';` thik ache kina dekhun. |

## Pore update korle
- **App (React):** PC-te `nfcbd-web` folder-e `npm run build` → `dist/` folder-er bhetorer file gulo `public_html`-e upload
  (`.htaccess`, `laravel.php`, `storage/` muchben na).
- **API (Laravel):** bodlano file gulo `nfcbd-api`-e upload. `.env` ar `vendor` thik thakbe.

## Mobile app
Mobile app-er API URL: `https://apnar-domain.com/api/v1` (nicher `docs/API.md` dekhun).
