# Nexora Esports — CPanel Deployment Guide
# ============================================
# Follow these steps EXACTLY. Nothing will break.

## STEP 1 — Login to CPanel
- URL: https://srv3.cloudpowersdns.com:2083/
- Username: nexoraes
- Password: f!N36N7k4cTUa-

## STEP 2 — Set up Python App
1. CPanel Home → "Setup Python App" (or "Python App" in Software section)
2. Click "+ Create" (top left)
3. Settings:
   - Python version: 3.11 (or 3.12 if available, NOT 2.x)
   - Application root: public_html   (or leave default)
   - Application URL: https://nexoraesport.com
   - Application startup file: passenger_wsgi.py
   - Passenger entry point: passenger_wsgi.py
4. Click "Create"

## STEP 3 — Upload All Project Files
### Option A: File Manager (browser)
1. CPanel → File Manager → go to /public_html/
2. Upload EVERYTHING from D:\nexora_esports\ except:
   - .venv/ folder (virtual env — CPanel has its own)
   - __pycache__/ folders
   - .git/ folder
   - *.pyc files
   - venv/ folder
3. Files to upload:
   - app.py
   - passenger_wsgi.py
   - requirements.txt
   - Passengerfile.json
   - .htaccess
   - .env              (CRITICAL — has SMTP secrets + admin password)
   - nexora.db         (your database with all registrations)
   - static/ folder    (ALL of it — CSS, JS, images, uploads)
   - templates/ folder (ALL HTML templates)
   - templates/emails/ folder

### Option B: SSH Terminal (if available)
1. CPanel → Terminal
2. cd /home/nexoraes/public_html
3. Upload via SCP from your PC:
   scp -r D:\nexora_esports\app.py nexoraes@srv3.cloudpowersdns.com:~/public_html/
   (repeat for each file/folder)

## STEP 4 — Install Python Packages
1. CPanel → Terminal (or SSH)
2. Run these commands:
   cd /home/nexoraes/public_html
   pip install -r requirements.txt

3. If pip is not found, try:
   /home/nexoraes/virtualenv/nexoraesport.com/3.11/bin/pip install -r requirements.txt

## STEP 5 — Set File Permissions
1. CPanel → Terminal:
   chmod 664 /home/nexoraes/public_html/.env
   chmod 664 /home/nexoraes/public_html/nexora.db
   chmod -R 755 /home/nexoraes/public_html/static/
   chmod -R 755 /home/nexoraes/public_html/templates/

2. Make uploads writable:
   mkdir -p /home/nexoraes/public_html/static/uploads
   chmod 777 /home/nexoraes/public_html/static/uploads
   mkdir -p /home/nexoraes/public_html/static/Images/Registrations
   chmod 777 /home/nexoraes/public_html/static/Images/Registrations

## STEP 6 — Start the App
1. CPanel → "Setup Python App" → click on your app
2. Click "Restart" (green button)
3. Check "Log" tab for errors — should show "Passenger app starting..."

## STEP 7 — Verify Website
1. Open https://nexoraesport.com in browser
2. You should see the Nexora Esports homepage
3. Test: /register, /about, /admin/login
4. Test: submit a registration, check email sends

## STEP 8 — Nameservers (if not done)
Login to Onic Host client area:
- URL: https://onichost.com/c-panel/clientarea.php
- Email: nexora.esport.support@gmail.com
- Password: Rashid786!

Update domain nexoraesport.com nameservers to:
  dns1.cloudpowersdns.com
  dns2.cloudpowersdns.com

## TROUBLESHOOTING

### "Application Error" on first visit
→ App may need restart. CPanel → Setup Python App → Restart

### Static files (CSS/JS) not loading
→ Check /home/nexoraes/public_html/static/ exists and has correct permissions (755)

### Email not sending
→ Verify .env has correct SMTP_PASSWORD (Gmail app password)
→ Gmail may block: go to https://myaccount.google.com → Security → App passwords → create new

### Database errors
→ Ensure nexora.db is in /home/nexoraes/public_html/
→ chmod 664 nexora.db
→ App auto-seeds default settings on first run

### 500 Internal Server Error
→ CPanel → Errors tab (or error_log in public_html)
→ Usually: missing pip package or wrong Python version

### "ImportError: No module named flask"
→ You didn't run pip install. Go to Step 4.

### SSL/HTTPS not working
→ CPanel → SSL/TLS → ensure Let's Encrypt is active for nexoraesport.com
→ .htaccess forces HTTP→HTTPS automatically
