# Installing Hostledger on cPanel

These steps assume a standard shared/reseller cPanel hosting account —
nothing here requires root/SSH access.

## 1. Create a MySQL database

In cPanel, go to **MySQL Databases**:

1. Create a new database (e.g. `hostledger`).
2. Create a new database user with a strong password.
3. Add that user to the database with **All Privileges**.
4. Note the full database name and username — cPanel usually prefixes both
   with your cPanel account name, e.g. `cpaneluser_hostledger`.

## 2. Upload the files

Upload the contents of this package to a subdirectory of `public_html`
(e.g. `public_html/billing`) or a dedicated subdomain — either via
cPanel's **File Manager** (upload the zip, then extract it in place) or
via FTP/SFTP.

Do not upload it directly into the web root of a domain that already has
another site running, unless you intend Hostledger to be that whole site.

## 3. Set folder permissions

Hostledger needs `storage/logs/` and `storage/cache/` to be writable by
the web server. Most cPanel accounts default new folders to permissions
that already allow this; if the installer's requirements check (next
step) reports either as not writable, set them to `755` (or `775` if your
host requires it) via File Manager's permissions dialog.

## 4. Run the installer

Visit `https://yourdomain.com/billing/install/` (adjust the path to
wherever you uploaded it) in your browser. The wizard will:

1. Check PHP version and required extensions.
2. Ask for your database host/name/user/password/table prefix, and test
   the connection before continuing.
3. Import the database schema.
4. Create your first admin account.
5. Write `config.php` and lock itself — visiting `/install/` again
   afterward shows a "already installed" notice rather than re-running.

## 5. Set up cron jobs

In cPanel, go to **Cron Jobs** and add:

```
0 2 * * *  php /home/YOURUSER/public_html/billing/cron/billing.php
0 3 * * *  php /home/YOURUSER/public_html/billing/cron/overdue.php
0 4 * * *  php /home/YOURUSER/public_html/billing/cron/domain-renewal-reminders.php
```

Adjust the path to match where you uploaded Hostledger, and the PHP binary
path if your host uses a versioned one (e.g. `/usr/local/bin/php8.2`).
Running billing before overdue, and both before the domain reminder job,
avoids a same-day invoice being immediately evaluated as overdue.

## 6. Configure at least one payment gateway

Go to **Admin → Gateways** and enter API keys for Stripe, PayPal, and/or
Paystack. Nothing can actually be paid for online until at least one is
enabled — until then, use the "Mark as paid" button for manual
cash/bank-transfer payments.

## 7. Add a WHM server (for automatic hosting provisioning)

Go to **Admin → Servers**, and add the hostname of a server you control,
plus a WHM API token generated under **WHM → Development → Manage API
Tokens** on that server (never your WHM/root password). Hostledger tests
the connection before saving it. New paid orders provision automatically
on the first active server on file.

## 8. (Optional) Connect a domain registrar

Go to **Admin → Domain Registrars** and enter your eNom reseller
credentials if you want to sell domain registrations through Hostledger.

## Updating later

There is no automated updater yet. To apply a future update: back up your
database and `config.php`, replace the application files (everything
except your own `config.php` and `storage/`), and check the release notes
for any required database migration steps.

## Getting help

This is self-hosted software you run yourself — see the project's own
README.md and PROJECT_PLAN.md for what is and isn't implemented before
relying on it for real billing.
