# Namecheap cPanel deployment

Target: `https://ems.revenueboosters.org`

## 1. Create the Python application

In cPanel, open **Setup Python App** and choose **Create Application**:

- Python version: `3.11` (use `3.12` if 3.11 is unavailable)
- Application root: `ems_app`
- Application URL: `ems.revenueboosters.org` with `/` as the path
- Application startup file: `passenger_wsgi.py`
- Application entry point: `application`

Create the application and copy the virtual-environment activation command shown
by cPanel.

## 2. Upload files

Upload `ems-namecheap.zip` to the application root (`ems_app`) in File Manager and
extract it there. The application root must directly contain `manage.py`, `.env`,
`passenger_wsgi.py`, and the `horilla` directory.

The archive contains the existing `db.sqlite3` and `media` directory. Keep a local
backup of the archive until the live application has been verified.

## 3. Install and initialize

Open cPanel Terminal, activate the virtual environment using cPanel's command, and
run:

```bash
cd ~/ems_app
python -m pip install --upgrade pip setuptools wheel
pip install -r requirements.txt
python manage.py migrate
python manage.py collectstatic --noinput
python manage.py check --deploy
```

Do not run `makemigrations` or `createhorillauser`; the existing database is being
deployed and already contains the development data and accounts.

## 4. Restart and verify

Return to **Setup Python App** and click **Restart**. Then visit:

- `https://ems.revenueboosters.org/health/` (must return `{"status": "ok"}`)
- `https://ems.revenueboosters.org/`

If cPanel created a placeholder `passenger_wsgi.py`, replace it with the one from
this package. If the application fails, inspect `~/ems_app/stderr.log` or the error
log path shown in cPanel.

## Operational limitation

SQLite is retained so the existing data can go live on shared hosting. It is not
suited to many simultaneous writes. Back up `db.sqlite3` and `media` regularly and
move the application to a VPS with PostgreSQL if usage grows or database-lock errors
appear. In-process scheduled jobs are also not guaranteed to run continuously under
Passenger; configure important recurring tasks as cPanel Cron Jobs.
