# Deployment guide

## 1. cPanel (shared hosting / reseller / managed VPS with cPanel)

1. **Upload** — cPanel → File Manager → your home directory (not `public_html`) → Upload the ZIP → Extract → you get `/home/USER/syncinfinite-pos/`.
2. **Database** — cPanel → MySQL® Databases: create database `USER_sipos`; create user `USER_sipos` with a strong password; *Add User To Database* → **ALL PRIVILEGES**.
3. **Subdomain / document root** — cPanel → Domains (or Subdomains) → create `pos.syncinfinite.com`, set **Document Root** to `syncinfinite-pos/public`. This keeps `app/`, `storage/`, `.env` and `database/` outside the web root. *(Do not install into the corporate site's `public_html`.)*
   - If your host cannot set a custom document root: put the package in `public_html/pos-app/`, set the subdomain root to `public_html/pos-app/public`. The shipped `.htaccess` files deny direct access to `.env`, `.sql`, `.log`, `.lock` and `.json`, but a custom document root is strongly preferred.
4. **SSL** — cPanel → SSL/TLS Status → Run AutoSSL for the subdomain. Then keep `FORCE_HTTPS=true`.
5. **PHP** — cPanel → MultiPHP Manager: PHP 8.3 for the subdomain. MultiPHP INI Editor: `display_errors = Off`, `log_errors = On`, `memory_limit = 256M`, `upload_max_filesize = 8M`, `post_max_size = 8M`, `max_execution_time = 120` (demo install may need 300). Select PHP Extensions: `mysqli`, `mbstring`, `openssl`, `curl`, `gd`, `fileinfo`.
6. **Permissions** — directories 755, files 644, `storage/` 750 (recursively), `.env` 600. Never 777.
7. **URL rewriting** — `public/.htaccess` is included; `mod_rewrite` is enabled on cPanel hosts by default. If the app lives in a sub-path, uncomment and set `RewriteBase`.
8. **Install** — open `https://pos.syncinfinite.com/install/` (setup key in `storage/install.key`).
9. **Cron** — cPanel → Cron Jobs → *Once Per Minute* (or every 5 minutes if your host limits frequency):
   `/usr/local/bin/php /home/USER/syncinfinite-pos/cron/run.php >/dev/null 2>&1` (check the PHP path with your host; use the same PHP version as the site).
10. **SMTP** — reserved for future email notifications: set `SMTP_*` in `.env` (cPanel → Email Accounts to create `no-reply@…`).
11. **Production hardening** — `APP_ENV=production`, `APP_DEBUG=false`, `PAYMENTS_SIMULATOR_ENABLED=false`, `DEMO_MODE=false`; delete `public/install/`; confirm `https://pos…/.env` returns 403/404.
12. **Backups** — cPanel → Backup Wizard (daily) + see `docs/BACKUP_RESTORE.md`.

### Updating
1. Back up files and database. 2. Set `MAINTENANCE_MODE=true`. 3. Upload/extract the new version over the old one, **keeping** `.env` and `storage/`. 4. `php installer/cli.php migrate` (cPanel → Terminal) . 5. Set `MAINTENANCE_MODE=false`.

### Shared-hosting limitations
- No long-running workers: background work runs from cron only (webhooks, dunning, maintenance).
- Some hosts allow cron only every 5–15 minutes: webhook delivery latency grows accordingly.
- Hosts that block outbound HTTP will prevent webhook delivery.
- No Redis/queues required; everything is MySQL-backed.

## 2. VPS / cloud (Ubuntu 24.04 example)

```
apt install apache2 php8.3 php8.3-mysql php8.3-mbstring php8.3-curl php8.3-gd mariadb-server certbot python3-certbot-apache
a2enmod rewrite headers ssl
# vhost: DocumentRoot /var/www/syncinfinite-pos/public ; <Directory ...public> AllowOverride All </Directory>
certbot --apache -d pos.syncinfinite.com
crontab -u www-data -e   # * * * * * php /var/www/syncinfinite-pos/cron/run.php
```
Run MySQL with automated backups + binary logs (point-in-time recovery). Put the app behind a load
balancer only after moving sessions to a shared store (see `docs/ARCHITECTURE.md` → Scaling).

### Enterprise / larger deployments (documented, not included)
Managed MySQL with replicas, shared session storage (DB or Redis), object storage for uploads,
CDN/WAF (rate limiting, DDoS), centralized logging/metrics, a dedicated worker process for jobs.
