# cPanel Installation Guide (Simple)

Upload **everything** into `public_html`. You do **not** need a separate `application` folder.

## What you need

1. cPanel login  
2. A MySQL database + user (cPanel → **MySQL Database Wizard**)  
3. Write down: database name, username, password  
4. Your website address, e.g. `https://events.yourhotel.com`

## Step 1 — Choose PHP 8.2

cPanel → **MultiPHP Manager** → select your domain → **PHP 8.2** (or newer).

## Step 2 — Create the database

cPanel → **MySQL Database Wizard**:

1. Create a database  
2. Create a user with a strong password  
3. Add the user to the database with **ALL PRIVILEGES**

Keep the full names (often like `account_dbname` and `account_dbuser`).

## Step 3 — Upload the package into public_html

1. Download `venue-events-manager-cpanel.zip`  
2. cPanel → **File Manager** → open **`public_html`**  
3. Upload the ZIP **into `public_html`**  
4. Right-click the ZIP → **Extract**  
5. Confirm you see files such as:
   - `index.php`
   - `install/`
   - `assets/`
   - `app/`, `vendor/`, `storage/`, …

If File Manager shows an extra nested folder, move **all** files up so they sit directly inside `public_html`.

Your site root should look like:

```
public_html/
  index.php
  .htaccess
  install/
  assets/
  app/
  vendor/
  storage/
  ...
```

## Step 4 — Writable folders

In File Manager, set these folders to **755** (use **775** only if the installer complains):

- `storage` (and its subfolders)
- `bootstrap/cache`

Do not use **777** unless your host insists, and change it back afterward if you must.

## Step 5 — Run the installer

1. Open: `https://your-domain.com/install/`  
2. Wait until requirements show green  
3. Enter:
   - Application URL (your full website address)
   - Database host (usually `localhost`), port `3306`, name, username, password
   - Property name, timezone (e.g. `Africa/Nairobi`), currency (e.g. `KES`)
   - Administrator name, email, and password  
4. Click **Install Now**

When it finishes, you are taken to the login page.

## Step 6 — Secure the site

1. Log in with the admin account you created  
2. Open **Administration → Settings** and set logo / contacts  
3. **Delete** the `install` folder inside `public_html`  
4. Turn on **HTTPS** (cPanel SSL / AutoSSL)  

Optional: in `.htaccess`, uncomment the “Force HTTPS” lines once SSL works.

## Upgrades (already installed)

Every code or database change is shipped as a versioned package:

```
dist/v1.000.002/
  update_v1.000.002.sql
  venue-events-manager-v1.000.002.zip
  UPGRADE.txt
```

1. Import the `.sql` file in phpMyAdmin  
2. Upload the `.zip` into `public_html` and extract/overwrite  
3. **Do not overwrite** `.env` or `storage/app/attachments`

Details: [docs/VERSIONED_UPDATES.md](docs/VERSIONED_UPDATES.md)

Developers build a package with:

```bash
php scripts/build_version_update.php 1.000.002
```

## Optional — load demo data (SQL)

After a successful install, import sample bookings, quotes, invoices, and payments:

1. cPanel → **phpMyAdmin** → select your database  
2. **Import** → choose `database/demo_data.sql` from the extracted package (or upload that file)  
3. Click **Go**

Or from SSH:

```bash
mysql -u DB_USER -p DB_NAME < database/demo_data.sql
```

Safe to run more than once (it replaces previous `DEMO-*` rows).  
Logins: `admin@venue.local` / `sales@venue.local` / `finance@venue.local` / `reservations@venue.local` — password `password`.

## Troubleshooting

| Problem | Try this |
|---------|----------|
| Blank page / 500 | PHP must be 8.2+; check `storage/logs` if present |
| Database error | Recheck DB name/user/password; host is usually `localhost` |
| Permission error | Make `storage` and `bootstrap/cache` writable |
| Installer blocked | Remove `storage/app/installed` only if you are intentionally reinstalling |
| Assets / CSS missing | Confirm `assets/` is inside `public_html`, not buried in a subfolder |

Sensitive folders (`app`, `vendor`, `storage`, etc.) are blocked from the web by `.htaccess`. Keep that file in place.

## Rebuild packages (developers)

Fresh install ZIP (entire app into public_html):

```bash
php scripts/build_cpanel_release.php
```

Versioned upgrade for sites already installed:

```bash
# 1. Add database/updates/update_vX.YYY.ZZZ.sql (always bump app_version)
# 2. Build:
php scripts/build_version_update.php X.YYY.ZZZ
```

Output: `dist/vX.YYY.ZZZ/` (SQL + ZIP + UPGRADE.txt)

See [docs/VERSIONED_UPDATES.md](docs/VERSIONED_UPDATES.md).
