# Deploying RentNest (Laravel) on cPanel shared hosting

This package runs on ordinary **PHP hosting** (cPanel, and also Plesk, DirectAdmin and similar). No Node.js, no
Composer and no command line are needed on the server: the PHP libraries (`vendor/`) and the built web app
(`public/build/`) are already included, and a **setup wizard** in the browser does the rest.

**In short:** create an empty database → upload and extract the zip → point your domain at `rentnest/public`
→ open your site and follow the wizard.

## 1. Check your hosting plan

| You need | Details |
|---|---|
| PHP **8.3 or newer** | Laravel 13 requires it. In cPanel: *Select PHP Version* or *MultiPHP Manager*. 8.4 recommended. |
| PHP extensions | `pdo_mysql`, `mbstring`, `openssl`, `fileinfo`, `curl`, `tokenizer`, `xml`, `ctype`, `dom` — normally on by default. The wizard checks them for you. |
| MySQL 8.0+ or MariaDB 10.3+ | One empty database and one database user. |
| A domain or subdomain | The site must sit at the root of a domain or subdomain (`https://app.yourdomain.com`), not in a sub-folder. |
| SSL certificate | Free AutoSSL / Let's Encrypt from the panel is fine. Online payments require HTTPS. |
| Disk | About 60 MB for the app, plus uploaded photos and documents. |

## 2. Create an empty database

cPanel → **MySQL® Databases**:

1. **Create New Database**, e.g. `rentnest`. cPanel adds your account prefix, giving something like `cpuser_rentnest`.
2. **Add New User** with a strong password (use the password generator and copy it somewhere safe).
3. **Add User To Database** → pick the user and the database → tick **All Privileges** → *Make Changes*.

Note the full database name, user name and password. **You do not need phpMyAdmin**: the wizard builds the tables.

## 3. Upload the files

1. cPanel → **File Manager** → open your home folder (the one that *contains* `public_html`).
2. **Upload** `rentnest-laravel-deploy.zip` there, then right-click it → **Extract**. You now have `/home/USERNAME/rentnest/`.
   Keeping the app outside `public_html` means your settings, uploads and libraries can never be downloaded.
3. You can delete the zip afterwards.

### Point the domain at `rentnest/public` (recommended)

- **Subdomain or addon domain:** cPanel → **Domains** → *Create A New Domain* (or *Manage* an existing one)
  → untick *Share document root* → set **Document Root** to `rentnest/public` → *Submit*.

### If your main domain must stay on `public_html`

Some hosts lock the main domain to `public_html`. Then:

1. Move the **contents** of the extracted `rentnest` folder (not the folder itself) into `public_html`.
   (File Manager: open `rentnest`, *Select All*, *Move*, type `/public_html`.)
2. In `public_html`, rename `root.htaccess` to **`.htaccess`**. It routes every request into `public/` and blocks
   direct access to `.env`, `storage`, `vendor` and the database file.
3. After setup, test that `https://yourdomain.com/.env` and `https://yourdomain.com/storage/logs/` show an error
   page, not file contents.

## 4. Run the setup wizard

Open your site address, e.g. `https://app.yourdomain.com`. You are taken to **`/install`** automatically.

| Step | What happens |
|---|---|
| **Setup code** | So nobody else can set up your site before you do, a one-time code is saved on the server. In File Manager open `rentnest/storage/setup-code.txt` (right-click → *View*), copy the code and paste it into the page. |
| **Server check** | PHP version, extensions, upload limits, writable folders and HTTPS. Anything marked **Fix** tells you exactly where to change it in cPanel. Press *Check again* after changing it. |
| **Database** | Enter the database name, user and password from step 2 (host `localhost`, port `3306`). The wizard tests the connection, explains any mistake in plain words, and builds all the tables. |
| **Site details** | Site name and address (filled in for you). Leave *redirect to https* off if cPanel's *Force HTTPS Redirect* is on. |
| **Email** (optional) | The email account RentNest sends from (see [Email](#email) below). The wizard signs in to your mail server to check the password before saving. You can skip it and add it later. |
| **Owner account** | Your name, email and password (10+ characters). This is the **superuser**, the one account that can do everything. |
| **Finish** | Switches the site on, deletes the setup code and closes `/install` for good. It then shows your **encryption key** once (save it in a password manager) and the **cron job** to add (next section). |

Behind the scenes the wizard writes your settings into the `.env` file in the app folder (created automatically
on the first visit, with a random encryption key). To see it in File Manager, use *Settings → Show Hidden Files*.

### Email

RentNest emails people to confirm their address, reset forgotten passwords, and (in later versions) send receipts and reminders.

1. cPanel → **Email Accounts** → *Create*, e.g. `noreply@yourdomain.com`.
2. Next to the account, *Connect Devices* shows the **outgoing server** (usually `mail.yourdomain.com`, port **465**, SSL).
3. Enter these in the wizard's Email step, or later in `.env`:

```ini
MAIL_MAILER=smtp
MAIL_SCHEME=smtps
MAIL_HOST=mail.yourdomain.com
MAIL_PORT=465
MAIL_USERNAME=noreply@yourdomain.com
MAIL_PASSWORD="the account password"
MAIL_FROM_ADDRESS=noreply@yourdomain.com
MAIL_FROM_NAME="RentNest"
```

For port 587 use `MAIL_SCHEME=smtp`. Then Backend → **Platform settings** → *Send me a test email*.
Send from an address on your own domain, or emails end up in spam; cPanel → **Email Deliverability** should show SPF and DKIM as valid.

### Cron job (scheduled tasks)

One cron job runs RentNest's scheduled tasks every minute and sends queued emails. cPanel → **Cron Jobs** →
*Common Settings*: **Once Per Minute (\* \* \* \* \*)**, and paste the command shown at the end of the wizard
(also in Backend → **Platform settings**). It looks like:

```text
cd /home/cpuser/rentnest && /opt/cpanel/ea-php84/root/usr/bin/php artisan schedule:run >> /dev/null 2>&1
```

The PHP path must be the same PHP version as the site (8.3 or 8.4); `/usr/local/bin/php` is often an older default.
Within two minutes Platform settings shows **Scheduled tasks: Running**. Until the job exists, emails are sent while
the page waits (a little slower) and automatic tasks do not run.

## 5. Go-live checklist

1. Sign in with the owner account.
2. Add the **cron job** and check Platform settings shows *Scheduled tasks: Running* and *Email: Set up* (send a test email).
3. Backend → **Platform settings**: enter your Paystack and/or Flutterwave keys, switch them on and switch
   **Demo checkout off**. In your Paystack / Flutterwave dashboard allow the callback URL
   `https://your-domain/pay/callback`, and set the **webhook URL** shown on each gateway's card
   (`https://your-domain/api/webhooks/paystack` or `.../flutterwave`). Paystack: *Settings → API Keys & Webhooks*.
   Flutterwave: *Settings → Webhooks*, with a secret hash you make up and also enter in Platform settings.
   Webhooks confirm a payment even when the payer closes the page before coming back.
4. Backend → **Users & roles**: create accounts for your administrators and staff.
5. HTTPS: cPanel → **SSL/TLS Status** → *Run AutoSSL* if needed, then **Domains** → switch on **Force HTTPS Redirect**.
6. Run one complete cycle with real test accounts before inviting users: register a landlord and a tenant,
   add a property with a photo and map pin, apply with a document, approve, sign, pay a small rent, check
   the receipt (and its PDF) and notifications, raise a maintenance request, and check the dashboard. Try *Forgot your
   password?* once to confirm reset emails arrive.
7. Have the tenancy-agreement template and quit-notice wording reviewed for your state's tenancy law.

## 6. Backups

- **Database:** cPanel → **Backup** (or phpMyAdmin → Export), or the panel's scheduled backups.
- **Uploaded files:** `public/uploads/` (photos), `storage/app/private/documents/` (tenants' documents) and
  `storage/app/private/messages/` (message attachments).
- **`.env`:** keep a copy; the `APP_KEY` inside it is required to decrypt saved bank details and gateway keys.

## 7. Updating to a new version

1. Back up as above.
2. Upload the new zip to the same place and extract it over the `rentnest` folder. Your `.env`, uploaded photos and
   documents are not in the zip, so they are kept, and the wizard does not run again.
3. Sign in as the owner. If the new version changes the database, the Backend overview says **database update(s)
   waiting**: open **Platform settings** and press **Apply database update** (with SSH you can run
   `php artisan migrate --force` instead). Until then, features that use the new tables may show errors.
   Each update is listed in the release notes.
4. If the site shows errors straight after an update, delete `config.php`, `routes-v7.php` and `events.php`
   from `bootstrap/cache/` if they exist (stale caches), then reload.

## 8. Troubleshooting

| Symptom | Likely cause and fix |
|---|---|
| "could not create the .env settings file" | The `rentnest` folder is not writable. File Manager → select it → *Permissions* → 755. |
| The setup page says `storage` is not writable | File Manager → `storage` → *Permissions* → 755, including subfolders. Never use 777. |
| Lost the setup code | It is always in `storage/setup-code.txt` until setup finishes. If you deleted the file, reload `/install` and a new one is made. |
| "Too many wrong codes" | Wait 15 minutes, then paste the code exactly (the dashes are optional). |
| Want to run the wizard again | Only before it finishes. Afterwards, change settings in the app or in `.env`. In an emergency you can set `APP_INSTALLED=false` in `.env`, reload `/install` and set it back when done. Existing data is kept. |
| White page or "500 Server Error" | Read `storage/logs/laravel-*.log`. Common causes: PHP older than 8.3 or `storage` not writable. Temporarily setting `APP_DEBUG=true` in `.env` shows the error on screen. Set it back to `false` afterwards. |
| `Your Composer dependencies require a PHP version ">= 8.3.0"` | Switch the domain to PHP 8.3 or 8.4 (*Select PHP Version* / *MultiPHP Manager*). |
| Database errors after setup (`Access denied`, `Base table or view not found`) | The database password was changed or the database was replaced. Correct `DB_*` in `.env`. |
| Sign-in works but every page says "Please sign in" | The host strips the Authorization header. The included `.htaccess` files restore it; make sure `public/.htaccess` was uploaded (it is a hidden file). |
| "Too many redirects" | Both the panel and the app redirect to HTTPS. Set `FORCE_HTTPS=false` in `.env`. |
| Pages load without styling or say "Vite manifest not found" | `public/build/` is missing. Re-upload it from the zip. |
| Photos or documents fail to upload | `public/uploads` or `storage/app/private` not writable, or the file is over 8 MB. The panel's `upload_max_filesize` must be at least 10M (the wizard's server check shows it). |
| Emails do not arrive | Platform settings → *Send me a test email* shows the mail server's answer. Check the spam folder, that `MAIL_FROM_ADDRESS` is on your domain, and cPanel → **Email Deliverability**. `MAIL_MAILER=log` means emails are only written to `storage/logs`. |
| Platform settings says *Scheduled tasks: Not running* | The cron job is missing or uses the wrong PHP. Copy the command from Platform settings exactly; cPanel emails the cron output to you if you remove `>> /dev/null 2>&1` while testing. |
| *Failed background tasks* on the overview | Usually a wrong mail password. Fix `.env`; failed records are cleared automatically after 30 days. Details are in `storage/logs`. |
| Password-reset link says *invalid or expired* | Links work for 60 minutes and once only. Ask for a new one; only the newest link works. |
| A payment went through at Paystack/Flutterwave but RentNest still shows it unpaid | The payer closed the page before returning and the webhook is not set up, or its URL/secret hash is wrong. Set it as in the go-live checklist; the gateway resends recent events. |
| Tenants get no rent reminders or late fees | Scheduled tasks are not running (see Platform settings), or the landlord switched them off in Settings → Billing & reminders. Reminders and late fees run once each morning. |
| A subscribed calendar shows no visits, or old times | Calendar apps fetch the link every few hours (Google can take up to a day). Check the link opens in a browser and downloads a file; if someone made a *New link*, subscribe again with it. |
| "You are posting too quickly" or "Too many payment attempts" | A rate limit (see Notes and limits). Wait a minute (or ten for payments) and try again. |
| The annual statement PDF times out | Very large portfolios on a slow host. Choose one property at a time, or use the statement CSV. |
| "This item is no longer available to buy online" or "Someone else is paying" | Another buyer started checkout in the last 30 minutes, or the item was sold or delisted. The hold ends by itself. |
| A logo or font does not show | Logos given as an address must start with `https://`. After changing the font, reload; some ad-blockers block Google Fonts. |
| "Your plan does not include …" | The person's plan leaves that module out. Change their plan (Customize → Subscribers, or they upgrade under My plan) or the standard plan for their account type. |
| A Paystack plan renewal did not extend the plan | The webhook URL is missing or wrong in Paystack. Renewals are recorded from Paystack's `charge.success` webhook. |
| A booking page says "not available" | The agent has not switched it on (Tours → Booking page), or their account is suspended. |
| Tour follow-ups or campaign emails do not go out | Scheduled tasks are not running (see Platform settings). Campaign emails to unsubscribed clients or clients without an email are skipped and listed as such under Email → Sent emails. |
| Visitors see "The forum is open to members only" | *Visitors can read the community forum* is off in Platform settings → General. |
| The map area is grey | Map tiles come from OpenStreetMap over the internet; a visitor's network or ad-blocker may block them. |

## 9. Setting up without the wizard (advanced)

If you prefer, or your host has SSH:

1. Import `database/rentnest-mysql.sql` into the empty database with phpMyAdmin (*Import* tab), or run
   `php artisan migrate --force` over SSH.
2. Copy `env.production.example` to `.env`, fill in `APP_URL` and the `DB_*` values, set **`APP_INSTALLED=true`**,
   and uncomment and fill in `ADMIN_NAME`, `ADMIN_EMAIL` and `ADMIN_PASSWORD`.
3. Load the site once (the key and owner account are created), sign in, then delete the `ADMIN_PASSWORD` line.
4. Fill in the `MAIL_*` values and add the cron job as described under [Email](#email) and [Cron job](#cron-job-scheduled-tasks).

## 10. Notes and limits

- **Payouts.** Payments land in your gateway account. Backend → **Payouts** lists each person's share of every payment
  (the landlord, the estate manager's portfolio commission, the contractor). With **automatic payouts** off (the default),
  pay them from your bank or gateway dashboard and press *Mark paid*. Switched on, shares of payments collected through
  **Paystack** are sent with Paystack Transfers every five minutes (by the cron job). Before switching on:
  1. In Paystack, enable Transfers on your business account, keep the balance funded, and turn **off OTP for transfers**
     (*Settings → Preferences*); otherwise every transfer fails asking for an OTP.
  2. Make sure the Paystack webhook URL is set (see the go-live checklist) so finished and reversed transfers are recorded.
  3. Ask landlords, estate managers and contractors to add their account in *Settings → Payment details*; it is checked
     with the bank. Shares for someone without a checked account wait (status *no bank details*) and go out once they add one.
  Money collected through Flutterwave or demo checkout is never sent from the Paystack balance; it stays *pay by hand*.
  Superusers get an email when a transfer fails, and can retry it or mark it paid from Backend → Payouts.
- **Chat and notifications refresh every few seconds** (polling), which works on any host.
- **Email** (confirmations, password resets, receipts with a PDF, rent reminders) needs the `MAIL_*` settings; without them it is only logged.
- **The public site** (home page, search, listings, compare) is open to everyone; only properties marked *listed* appear.
  Listing visits are counted once per visitor per day using a keyed one-way hash, so no IP addresses are stored.
  People can save a search and get a morning email when new matching homes are listed.
- **Agreements** are signed by both parties with a typed name and a drawn signature. Tenants get an emailed signing link
  (valid 14 days; sending a new one cancels the old). The signed PDF is saved as the tenant's document and emailed to both.
  Each morning tenancies ending within 30 days trigger one alert to both parties, and tenancies past their end date are ended.
  The standard agreement and notice wording are general; have them checked against your state's tenancy law.
- **Billing runs each morning** in `SCHEDULE_TIMEZONE`: bills past their due date are marked overdue, late fees are added after
  each landlord's grace period (default 5% after 5 days, once per bill), then reminders go out. Each landlord or estate manager
  changes this in *Settings → Billing & reminders*. Rent schedules are still created in full when the tenant signs.
- **Maintenance visits** get one reminder (in-app and email with a calendar invite) three days before, sent with the
  morning reminders and following the landlord's *upcoming reminders* switch. Everyone can subscribe to their visits from
  *Maintenance → Calendar → Add to my calendar app*: the private link works with Google Calendar, Outlook and Apple Calendar,
  which refresh it on their own schedule (usually every few hours). Times in emails are in `SCHEDULE_TIMEZONE`.
  The link uses `APP_URL`, so set that to the public `https://` address before people subscribe.
- **Inspections** are scheduled by the landlord or estate manager for a tenancy; the tenant reports each area (condition,
  notes, photos) by the due date. Tenants get an email when one is scheduled and a reminder two days before; late reports
  are marked overdue each morning and both sides are told once. Inspection photos, like maintenance photos, are stored
  under unguessable names in `public/uploads/public`, so anyone given a photo's exact link can open it.
- **Expenses** are per property (optionally per job) and visible to everyone who manages the property. Contractor payments
  made through RentNest are added automatically and cannot be deleted. Receipts are private documents.
- **Reports** (landlords and estate managers → *Reports*) show income received, expenses, net income, occupancy and the
  running cash-flow total for a calendar year, for all properties or one, with CSV downloads and an annual statement PDF.
  Income is counted on the day a bill was paid through RentNest and is before any management commission. The PDF lists up
  to 150 properties one by one (the totals always cover all of them; the statement CSV lists every property).
- **Photos lose their hidden details on upload.** Location (GPS), camera, date taken and comments are removed from JPEG,
  PNG and WebP files, without re-compressing them; phone photos keep the right way up. Photos uploaded before this version
  are unchanged.
- **Rate limits** (per signed-in person): starting or confirming payments 20 per 10 minutes; new forum posts, comments,
  marketplace items, enquiries, applications and maintenance requests 10 per minute and 300 per day; chat messages 40 per
  minute; uploads 60 per 10 minutes. Sign-in, sign-up and password reset are limited per IP address. People who hit a
  limit see a "please wait" message.
- **Backend → Platform settings → General:** switch new sign-ups off (people with accounts still sign in; administrators
  can still create accounts), set a support email shown in every email footer and on the public site, show an
  announcement banner to everyone who is signed in, and choose whether visitors can read the forum and browse the
  marketplace without signing in (both on by default).
- **Backend → Customize (superuser only).**
  - *Branding:* app name (used in menus, page titles, emails, receipts and PDFs), tagline, logo, browser icon, and the
    sign-in screen's heading, points and background photo. Images can be uploaded or given as an `https://` address.
  - *Theme:* main and second colour (buttons use a deeper shade automatically when white text would be hard to read),
    light / dark / follow-device for everyone (each person can override it in Settings), corner style and font. Google
    Fonts load from Google's servers, which see visitors' IP addresses; the system fonts need no outside service.
  - *Layout:* menu on the left or across the top, hide optional menu items, footer text and links, and a maintenance
    banner on every page (the site keeps working).
  - *Home page:* the heading, text, button and the cards at the bottom. Articles are written under Backend → Blog.
  - *Modules:* switch Payouts, Maintenance, Inspections, CRM, Reports, Marketplace, Forum or Blog off for everyone.
- **Plans and subscriptions.** Under Customize → Plans the superuser creates plans (which modules, which account types,
  monthly and/or yearly price), chooses the standard plan for each account type, and can put someone on a plan by hand
  (e.g. a trial) until a date. With no plans, everyone gets every module that is switched on. Paid plans are bought under
  *My plan* and renew through **Paystack subscriptions**:
  1. Add your Paystack secret key and set the webhook URL (go-live checklist); the Paystack plans are created
     automatically at the first purchase.
  2. Renewals, failed renewals (3 days' grace) and cancellations arrive by webhook; the daily `rentnest:plans` task ends
     lapsed plans. Cancelling keeps the plan until the end of the paid period.
  3. Plan fees are the platform's income (paid to the gateway account, never paid out). Demo checkout activates a plan
     for one period without renewing. Flutterwave cannot be used for plans.
  Limits apply to landlords, estate managers (and their staff), agents and the other account types a plan is for; a
  tenant's repair requests follow their landlord's plan. Automatic payouts for someone whose plan lacks *Payouts* are
  listed as "pay by hand".
- **Community.** The forum and marketplace are public to read unless switched off above; visitors see first names and
  initials only. Forum posts can carry up to five tags and be upvoted (one vote per person, not your own); moderators pin
  posts under Backend → Moderation. Moderators can also *delist* a marketplace item with a reason the seller sees.
- **Blog.** Backend → **Blog** (permission *content*): new posts are drafts; *Publish* puts them on `/blog`. The text uses
  a few simple codes (`## heading`, `- list item`, `**bold**`, `[link](https://…)`); HTML is shown as plain text.
- **Marketplace "Buy now".** A seller who has bank details in *Settings → Payment details* can let buyers pay online.
  Starting checkout holds the item for 30 minutes; once paid the item is marked sold, a chat opens to arrange handover,
  and the full price is added to Backend → Payouts as a *seller* payout (paid like other payouts). RentNest does not hold
  the money in escrow or handle disputes: decide your refund rules before switching this on. If a payment arrives after
  an item was sold or taken down, superusers are notified to refund it.
- **Messages** can include up to three photos or PDFs (8 MB each), kept privately in `storage/app/private/messages`
  (include it in backups). Senders can edit a message for 60 minutes and delete it; deleted messages stay visible to
  moderators.
- **Agents (CRM).** *Agent* accounts get a client pipeline (lead → contacted → viewing → offer → negotiation → won/lost)
  with notes, tasks, matching homes, retainers and email. Their public booking page (`/book/their-name`, off until they
  switch it on under *Tours → Booking page*) offers free times from their weekly hours, minus days off, the daily limit
  and tours already booked. Times use `SCHEDULE_TIMEZONE`. A booking is confirmed at once: the visitor gets an email with a
  calendar invite and a cancel link, and the agent a notification. Every 5 minutes the cron job marks finished tours as
  completed; two hours later the visitor gets one follow-up email (not after a *no-show*).
- **Agent emails** come from the site's address with the agent's name, and replies go to the agent. Every email has an
  unsubscribe link (and a one-click unsubscribe header). Links are counted when clicked, through a signed redirect;
  there is no open tracking. Campaigns and sequence emails go out in batches of `CRM_EMAILS_PER_RUN` (default 40) every
  5 minutes, about 480 an hour; lower it in `.env` if your host's hourly email limit is smaller. Without the cron job,
  a campaign sends its first 200 straight away and the rest wait.
- **Retainers.** An agent can ask a client for a retainer. The client pays it online after signing in with the email the
  agent has for them (Payments page, or *My home search*), and it is paid out to the agent like other payouts.
- **Buyers and sellers.** *Home buyer* accounts get "My home search" (saved homes, saved searches, enquiries). *Home seller*
  accounts list their own homes for sale only, with views, saves and enquiries; letting needs a landlord account.
- **Property assignment:** Backend → Property listings → *Assign* moves a property to another owner and/or sets or removes
  its estate manager. Everyone affected, including current tenants, is notified. The property leaves its old portfolio
  when the manager changes. Bills already issued stay as they are; from then on tenants pay the new manager (or owner).
- **Audit log** entries record the IP address and browser, and for edits the old and new value of each changed field
  (never passwords or keys). Search by IP address, or filter by record type.
- **Email volume.** Many hosts cap outgoing email (often 100–500 an hour per domain). A large site's morning reminders can
  pass that; the queue retries, but ask your host for the limit, or send through a transactional email service by
  changing the `MAIL_*` settings.
- **Map tiles** use OpenStreetMap's public servers, meant for light use. Switch to a paid tile provider for a busy site.
- **Demo data** (`php artisan migrate:fresh --seed`) is for local testing only; it refuses to run with `APP_ENV=production`.
  To show the demo on a hosted site, run `php scripts/demo-sql.php` on your own computer: it writes
  `rentnest-demo-data.sql` (import it with phpMyAdmin; it **replaces** existing users and data, keeps site settings) and the
  demo photos to upload into `public/uploads/public`. Dates in it are relative to the day it was made.

## 11. Changing the code later

On a computer with PHP 8.3+, Composer and Node.js:

```bash
composer install
```

```bash
npm install
```

```bash
php scripts/package.php
```

The last command runs the tests, builds the web app, regenerates `database/rentnest-mysql.sql` and produces
a new `rentnest-laravel-deploy.zip`.
