# Hostiva — Deployment Checklist

## XAMPP (local)

1. Copy `hostiva` folder to `C:\xampp\htdocs\hostiva`
2. Start **Apache** + **MySQL**
3. Open `http://localhost/hostiva/install.php`
4. Set App URL: `http://localhost/hostiva`
5. DB: host `127.0.0.1`, name `hostiva`, user `root`, pass *(empty)*
6. Complete wizard → **delete `install.php`**
7. Login: `http://localhost/hostiva/pages/login.html`

### Existing database upgrade

```sql
mysql -u root -p hostiva < database/migrations_001_v3_1_0.sql
```

Ensure `config/config.php` includes:

```php
'base_path' => '/hostiva',
```

---

## cPanel (production)

1. Create MySQL database + user in cPanel
2. Upload entire `hostiva` folder to `public_html/hostiva/` (or subdomain root)
3. Visit `https://yourdomain.com/hostiva/install.php`
4. App URL: `https://yourdomain.com/hostiva`
5. `base_path` auto-set from URL path during install
6. Set `cookie_secure` => `true` in config when on HTTPS
7. Delete `install.php`
8. PHP 7.4+ with `pdo_mysql`, `mbstring`, `json`

### Permissions (typical)

| Path | Permission |
|------|------------|
| `config/` | 755, `config.php` 640 |
| `logs/` | 755 writable |
| `uploads/` | 755 writable |

### `.htaccess`

- Root + `api/` rewrite enabled (AllowOverride All)
- Uncomment HTTPS redirect in root `.htaccess` when SSL active

---

## VPS / Apache

- DocumentRoot or Alias to `hostiva/`
- Same steps as cPanel
- Enable `mod_rewrite`, `mod_headers`
- Cron (optional): purge old `password_resets` / `user_sessions`

---

## Post-deploy security

- [ ] Delete `install.php`
- [ ] Change admin email + password
- [ ] `app.env` = `production`, `debug` = false
- [ ] HTTPS only
- [ ] Database backups nightly
- [ ] Do not commit `config/config.php`

---

## Troubleshooting

| Symptom | Fix |
|---------|-----|
| Blank pages | F12 Console — was `status` conflict; use this build |
| 401 after login | Set `base_path` to folder path (e.g. `/hostiva`) |
| Database connection failed | Check `config/config.php` credentials |
| 419 CSRF | Refresh page; clear cookies |
| 403 Forbidden | Run migrations; super_admin has all permissions |

---

## Package contents

```
hostiva/
├── api/           Backend router + controllers
├── assets/        CSS + JS (hostiva.js, layout.js)
├── config/        config.sample.php → config.php
├── database/      hostiva_v3.sql + migrations
├── docs/          BLUEPRINT + this checklist
├── pages/         All UI modules incl. channels.html
├── logs/          PHP errors
├── uploads/       User files
├── install.php    One-time (DELETE after)
└── index.html     Landing
```
