# Putting Hunt House Chores on cPanel (Siteocity)

This takes about 20 minutes. Do the steps in order. Anything in `code style` is typed or clicked exactly as shown.

## Part 1: On your Mac (about 5 minutes)

Open the Terminal app and run these one at a time.

1. Go to the project and check the tests pass:

   ```
   cd ~/hunt-house-chores
   php tests/periods_test.php
   ```

   You should see `All 81 checks passed.`

2. Create your config. It asks for Josh's password, Jess's password (typing is hidden, you type each twice), and the date to start tracking. Press Enter to accept the suggested date.

   ```
   php scripts/make-config.php
   ```

   Passwords need at least 8 characters. The usernames are `josh` and `jess`. The passwords are stored only as scrambled hashes, never as plain text.

3. Build the upload file:

   ```
   ./scripts/build-zip.sh
   ```

   This puts `hunt-house-chores-deploy.zip` on your Desktop. It contains your password hashes, so delete it from your Desktop and from cPanel when you are done.

## Part 2: In cPanel (about 15 minutes)

### 2.1 Check the PHP version

1. In cPanel, open **MultiPHP Manager**.
2. Tick your domain and set its PHP version to **8.1 or newer** (8.2 or 8.3 is fine). Click Apply.
3. SQLite support (`pdo_sqlite`) is included with PHP on standard cPanel hosting, so there is normally nothing to switch on. Some hosts have a **Select PHP Version** screen with an **Extensions** tab; yours may not, and that is fine. If it exists, make sure **pdo_sqlite** and **sqlite3** are ticked.

If the site later shows an error mentioning `could not find driver`, the extension is missing. Ask Siteocity support: "Please enable the pdo_sqlite and sqlite3 PHP extensions for ea-php82 on my account."

### 2.2 Upload the files

1. Open **File Manager** and click your home folder in the left panel (it is named after your cPanel username, for example `/home/yourname`). Do not open `public_html`.
2. Click **Upload**, choose `hunt-house-chores-deploy.zip`, and wait for it to finish.
3. Go back to File Manager, right-click the zip, and choose **Extract**. Extract into the home folder.
4. You should now have `/home/yourname/hunt-house-chores/` with `app`, `config`, `data`, `public`, and `scripts` inside it.

Only the `public` folder is ever shown on the internet. Everything else (including your config and database) stays private, as long as you do step 2.3 exactly.

### 2.3 Move the folder into `public_html` and create the subdomain

Some cPanel setups only allow a site's folder to live inside `public_html` (the Document Root box has a fixed `/public_html/` in front of it). Do this so it works either way.

1. In File Manager, right-click the `hunt-house-chores` folder (in your home folder) and choose **Move**. Change the path to `/public_html` and click **Move File(s)**. You should now have `public_html/hunt-house-chores/`.
2. Open **Domains** and click **Create A New Domain**.
3. In **Domain**, type a subdomain such as `chores.hunthouse10.com`.
4. **Untick** "Share document root".
5. In **Document Root**, after the fixed `/public_html/`, type exactly `hunt-house-chores/public`.
6. Click **Submit**.

Only the `public` folder is shown on the subdomain. The `app`, `config`, and `data` folders each contain a `.htaccess` file that blocks web access, in case someone tries to reach them through the main domain.

### 2.3b Keep the database outside `public_html`

1. In File Manager open `public_html/hunt-house-chores/config/`, right-click `config.php`, and choose **Edit**.
2. Add this line just before the final `];` (replace `hunthous` with your cPanel username if it is different):

   ```
   'data_dir' => '/home/hunthous/hunt-house-data',
   ```

3. Click **Save Changes**. The app creates that folder the first time it runs.

### 2.4 Turn on HTTPS

The site will not let you sign in over plain HTTP. In cPanel open **SSL/TLS Status**, find your domain, and click **Run AutoSSL**. Wait a few minutes until it shows a lock or "Domain Validated". Then visit `https://your-domain` and confirm the padlock appears.

### 2.5 Try it

1. Visit `https://your-domain`. You should see the Hunt House Chores sign-in page.
2. Sign in as `josh` with Josh's password. You should see the chore list.
3. In File Manager open your home folder. A new folder `hunt-house-data` should exist with a file called `hunt-house-chores.sqlite` inside. That is your database.
4. On your phone, open the same address, sign in, and let LastPass save the login. You stay signed in on each device for 90 days.

## Part 3: Quick check that it is private

- Visit `https://your-domain/config/config.php`, `https://your-domain/app/` and `https://your-domain/data/`. Each should show an error (404 or 403), never a file or a listing. Also try `https://hunthouse10.com/hunt-house-chores/config/config.php` and `https://hunthouse10.com/hunt-house-chores/app/bootstrap.php` (the main domain). These must also show an error.
- Open the site in a private/incognito window. You should only ever see the sign-in page.
- Wrong password five times in a row locks that connection out for 15 minutes.

## Day-to-day

- **Backups:** now and then, download `hunt-house-data/hunt-house-chores.sqlite` (in your home folder) from File Manager.
- **Change a password:** on your Mac run `php scripts/make-config.php` (answer `yes` to overwrite), rebuild the zip, upload, and extract it over the old one. Then sign everyone out: in cPanel **Terminal** run `cd ~/public_html/hunt-house-chores && php scripts/logout-all.php`.
- **Change the chore list:** edit `config/chores.php` (File Manager, right-click, Edit). Keep each chore's `id` the same forever; change only `name` or `frequency` if needed.
- **Update the app later:** rebuild the zip on your Mac and extract it over the old files. Your database is not in the zip, so your history is safe.

## If something goes wrong

| What you see | What to do |
|---|---|
| Blank page or "500 Internal Server Error" | Check step 2.1 (PHP 8.1+ and `pdo_sqlite`). Then, in File Manager, click **Settings** (top right), tick **Show Hidden Files**, and read `public_html/hunt-house-chores/public/error_log` for the reason. |
| `Missing config/config.php` | The zip was built without a config. Redo Part 1 step 2 and 3, then re-upload. |
| "unable to open database file" | PHP cannot write to `hunt-house-chores/data`. In File Manager right-click your home folder's `hunt-house-data` folder (or `hunt-house-chores/data` if you skipped step 2.3b), choose **Change Permissions**, and set it to `755` (try `775` if that does not help). |
| Sign-in just returns to the sign-in page | You are on `http://` and not `https://`. Finish step 2.4 and use the `https` address. |
| Dates look a day off | The app uses US Central time. Check `timezone` in `config/config.php` is `America/Chicago`. |
| Everything is overdue right after launch | `tracking_starts` in `config/config.php` is too early. Set it to the first day you want tracked. |
