# Codevra Workspace (`https://mail.codevra.in`) — cPanel Deployment & Installation Guide

## 1. Preserving Your Existing `codevra.in` Public Website
Deploy Codevra Workspace on its dedicated subdomain **`mail.codevra.in`** so your existing main website at `https://codevra.in` (`public_html/`) remains untouched:
1. Log in to **cPanel -> Domains -> Create A New Domain**.
2. Enter Domain: `mail.codevra.in`.
3. Uncheck **"Share document root"** and set the Document Root to `/home/CPANEL_USERNAME/mail.codevra.in` (or `/home/CPANEL_USERNAME/public_html/mail` if preferred).
4. Enable **AutoSSL** in **cPanel -> SSL/TLS Status** so `https://mail.codevra.in` serves over valid HTTPS.

## 2. Folder Layout on cPanel
Extract `codevra_workspace_cpanel.zip` so your directories match:
```text
/home/CPANEL_USERNAME/
├── private_codevra/          # OUTSIDE web root — inaccessible via HTTP
│   ├── config.php            # Auto-generated by install.php (chmod 600)
│   ├── config.example.php
│   ├── database.php
│   ├── schema.sql
│   ├── lib/
│   ├── storage/              # Encrypted/UUID Drive & Chat uploads
│   ├── logs/
│   └── backups/
└── mail.codevra.in/          # Document root of https://mail.codevra.in (contents of public_html/)
    ├── index.php
    ├── install.php           # Delete immediately after first-time setup!
    ├── .htaccess
    ├── api/
    ├── assets/
    ├── css/
    └── js/
```

## 3. PHP 8.2+ & Required Extensions (cPanel)
Open **cPanel -> MultiPHP Manager** (or **Select PHP Version**) and select **PHP 8.2** or **PHP 8.3** for `mail.codevra.in`. Ensure these extensions are enabled:
- `pdo_mysql` (required for MySQL/MariaDB)
- `openssl` (required for AES-256-GCM credential encryption & SMTP TLS)
- `imap` (required for real IMAP inbox synchronization in Codevra Mail)
- `mbstring` and `fileinfo` (required for MIME email decoding and upload validation)

## 4. Create MySQL Database & Run the First-Time Installer
1. Open **cPanel -> MySQL Database Wizard**, create database `CPANEL_USER_workspace` and user `CPANEL_USER_wsadmin` with a strong password, and grant **ALL PRIVILEGES**.
2. Visit **`https://mail.codevra.in/install.php`** in your browser.
3. Enter your MySQL credentials, IMAP/SMTP host (`mail.codevra.in`), and your first **Super Admin `@codevra.in`** email and strong password (min 10 characters).
4. Click **Initialize Database & Create Super Admin**. The installer automatically imports `schema.sql`, writes `private_codevra/config.php` with a fresh 256-bit `APP_KEY`, and locks itself via `private_codevra/install.lock`.
5. **Security Step**: Delete `install.php` from cPanel File Manager once setup completes.
