# Mapex Day 0 Launch Command Sheet

Use these commands in order. Replace placeholders in angle brackets.

## 1) Local preflight (Windows PowerShell)
```powershell
Set-Location C:\xampp\htdocs\finalproject
& "C:\xampp\php\php.exe" -l db.php
& "C:\xampp\php\php.exe" -l cart.php
& "C:\xampp\php\php.exe" -l collection.php
& "C:\xampp\php\php.exe" -l payment\payment.php
& "C:\xampp\php\php.exe" -l track_order.php
& "C:\xampp\php\php.exe" -l track_api.php
& "C:\xampp\php\php.exe" -l Admin\login.php
& "C:\xampp\php\php.exe" -l Admin\products.php
& "C:\xampp\php\php.exe" -l Admin\categories.php
```

## 2) Server connect (Linux host)
```bash
ssh <USER>@<SERVER_IP>
```

## 3) Backup current production
```bash
cd /var/www/<SITE_ROOT>
sudo cp -a current current_backup_$(date +%Y%m%d_%H%M%S)
mysqldump -u <DB_USER> -p'<DB_PASS>' <DB_NAME> > /var/backups/<DB_NAME>_$(date +%Y%m%d_%H%M%S).sql
```

## 4) Deploy new release
```bash
cd /var/www/<SITE_ROOT>
mkdir -p releases/<RELEASE_TAG>
rsync -av --delete <LOCAL_OR_CI_ARTIFACT_PATH>/ releases/<RELEASE_TAG>/
ln -sfn /var/www/<SITE_ROOT>/releases/<RELEASE_TAG> /var/www/<SITE_ROOT>/current
```

## 5) Set permissions
```bash
cd /var/www/<SITE_ROOT>/current
find . -type d -exec chmod 755 {} \;
find . -type f -exec chmod 644 {} \;
chmod -R 755 uploads userimg
```

## 6) Set environment variables (example)
```bash
export MAPEX_APP_ENV=production
export MAPEX_FORCE_HTTPS=1
export MAPEX_FORCE_SECURE_COOKIE=1
export MAPEX_SESSION_TIMEOUT=1800

export MAPEX_DB_HOST=127.0.0.1
export MAPEX_DB_PORT=3306
export MAPEX_DB_USER=<DB_USER>
export MAPEX_DB_PASS=<DB_PASS>
export MAPEX_DB_NAME=mapex

export MAPEX_SMTP_HOST=<SMTP_HOST>
export MAPEX_SMTP_PORT=587
export MAPEX_SMTP_USER=<SMTP_USER>
export MAPEX_SMTP_PASS=<SMTP_PASS>
export MAPEX_SMTP_ENCRYPTION=tls
export MAPEX_SMTP_FROM_EMAIL=<SMTP_FROM_EMAIL>
export MAPEX_SMTP_FROM_NAME=Mapex
export MAPEX_SMTP_REPLY_TO=<SMTP_REPLY_TO>

export MAPEX_FLW_PUBLIC_KEY=<FLW_PUBLIC_KEY>
export MAPEX_FLW_SECRET_KEY=<FLW_SECRET_KEY>
export MAPEX_FLW_CURRENCY=USD
export MAPEX_FLW_PAYMENT_OPTIONS=card,banktransfer,ussd
export MAPEX_FLW_WALLET_OPTIONS=banktransfer,ussd
export MAPEX_FLW_LOGO=<LOGO_URL>
```

## 7) Reload web/PHP services
```bash
sudo systemctl reload apache2 || sudo systemctl reload httpd
sudo systemctl restart php8.1-fpm || sudo systemctl restart php8.0-fpm || true
```

## 8) Quick HTTP checks
```bash
curl -I https://mapexstore.uk/home.php
curl -I https://mapexstore.uk/collection.php
curl -I https://mapexstore.uk/cart.php
curl -I https://mapexstore.uk/payment/payment.php
curl -I https://mapexstore.uk/track_order.php
```

## 9) Security checks (must deny)
```bash
curl -I https://mapexstore.uk/smtp-test.php
curl -I https://mapexstore.uk/run_import_from_img.php
curl -I https://mapexstore.uk/run_standardize_categories.php
curl -I https://mapexstore.uk/uploads/test.php
curl -I https://mapexstore.uk/userimg/test.php
```

## 10) Smoke flow checkpoints (manual)
```text
[ ] User signup/login works
[ ] Add to cart / update qty / remove works
[ ] Save shipping works
[ ] Flutterwave redirect opens and callback succeeds once only
[ ] Cash on delivery creates one order
[ ] Admin login works
[ ] Category/Product CRUD + bulk delete works
[ ] Tracking page + API respond correctly
```

## 11) Rollback (if needed)
```bash
cd /var/www/<SITE_ROOT>
ln -sfn /var/www/<SITE_ROOT>/current_backup_<TIMESTAMP> /var/www/<SITE_ROOT>/current
sudo systemctl reload apache2 || sudo systemctl reload httpd
```
