# cPanel installation guide (no terminal needed)

Applies to release 0.1.0 (milestone S0). Not yet verified on a real cPanel server; report anything that differs.

## Before you start
- cPanel hosting with PHP 8.3 or newer (cPanel > MultiPHP Manager) and one MySQL database.
- A domain with HTTPS (cPanel > SSL/TLS Status > run AutoSSL).

## 1. Create the database (cPanel > MySQL Databases)
1. Create a database. cPanel adds your account name in front (e.g. `cpuser_rent`).
2. Create a database user with a strong password.
3. Add the user to the database and tick ALL PRIVILEGES. Keep the TRIGGER privilege ticked; without it the system still works but shows a warning (see Troubleshooting).

## 2. Upload and place the files (cPanel > File Manager)
1. Upload `rental-manager-0.1.0.zip` to your home folder (the one that contains `public_html`). Select it, click Extract.
2. Inside the extracted folder you will see `rpms/`, `public_html/`, `docs/`.
3. Move `rpms/` so it is in your home folder beside `public_html` (outside the public web folder). This is the recommended layout: nothing private can be downloaded.
4. Open the extracted `public_html/` folder, select all (including the hidden `.htaccess`: Settings > "Show hidden files"), Move into your real `public_html/` (or the subfolder/addon-domain folder you want the system on).
5. If you can only use `public_html` and not the folder above it: put `rpms/` inside `public_html/` instead. It still works; the `.htaccess` files inside deny web access, but that protection relies on Apache/LiteSpeed. The installer shows a warning in that case.

Subfolder example: files in `public_html/rent/` are served at `https://domain/rent/`. Addon domains work the same way using that domain's own folder.

## 3. Optional but recommended: lock the installer before you start
Create a file `rpms/storage/install-key.txt` containing a long random word. The installer will ask for it. This stops a stranger finishing the installation before you do.

## 4. Run the installer
Open `https://your-domain/install`.
1. Requirements: every row must be PASS or WARN. A FAIL row tells you how to fix it in cPanel.
2. Database: host is normally `localhost`. The connection is tested before anything is saved.
3. Application: name, site address, timezone (default Africa/Nairobi), currency (KES), agency details, optional logo.
4. Create tables: creates all tables, indexes and relationships and the default roles. Safe to repeat if interrupted.
5. Administrator: your name, email, password (12+ characters, upper, lower, number).
6. Finish: generates the application key and a cron secret, locks the installer permanently, shows your sign-in link. **Copy the cron secret now; it is shown once.**

## 5. Scheduled tasks (cPanel > Cron Jobs), every 5 minutes
Option A (preferred, if your host allows PHP in cron):
`*/5 * * * * /usr/local/bin/php /home/CPUSER/rpms/cron.php`
Option B (URL only):
`*/5 * * * * curl -s -H "X-Cron-Key: YOUR_SECRET" "https://your-domain/cron/run" > /dev/null`
The secret goes in a header, not the address, so it stays out of access logs. If your host's cron can only call a URL, `?key=YOUR_SECRET` also works but is weaker because URLs are logged.

## 6. After installing
- Sign in, open Diagnostics, confirm everything is PASS or understood.
- Delete `rpms/storage/install-key.txt` if you created it.
- Take a database backup (cPanel > Backup or phpMyAdmin Export) before adding real data.
