# LIS Portal — cPanel Deployment Guide
## File Manager upload · SQLite · IP-only access

---

## What you need before starting
- [ ] cPanel login
- [ ] PHP 8.2 set in cPanel → **MultiPHP Manager** (select 8.2 for your domain/home)
- [ ] The `lis-portal.zip` deployment package

---

## Step 1 — Upload the zip

1. Log in to cPanel → open **File Manager**
2. Navigate to `public_html/`
3. Click **Upload** → upload `lis-portal.zip`
4. Once uploaded, right-click it → **Extract**
   - Extract into `public_html/` — this creates `public_html/lis-portal/`
5. Delete the zip after extraction to save space

Your file structure should now be:
```
public_html/
└── lis-portal/
    ├── app/
    ├── bootstrap/
    ├── database/
    │   └── database.sqlite   ← your data is here
    ├── public/
    │   ├── index.php
    │   ├── install.php
    │   └── .htaccess
    ├── storage/
    ├── vendor/
    └── .htaccess             ← routes /lis-portal/* into public/
```

---

## Step 2 — Set folder permissions

In File Manager, right-click each folder → **Change Permissions**:

| Folder | Permission |
|---|---|
| `storage/` | **755** (recursive — tick "apply to subdirectories") |
| `bootstrap/cache/` | **755** |
| `database/` | **755** |
| `database/database.sqlite` | **644** |

> **Tip:** Click `storage/` → top menu **Permissions** → check all boxes for Owner & Group, read-only for World, tick **Recurse into subdirectories** → Save.

---

## Step 3 — Run the web installer

1. Open your browser and go to:
   ```
   http://YOUR_SERVER_IP/lis-portal/public/install.php
   ```
   *(Replace `YOUR_SERVER_IP` with the actual IP of your server)*

2. **Step 1 — Server Check** page appears.
   All items should show ✓ OK. If anything fails, see Troubleshooting below.

3. Click **Continue →**

4. **Step 2 — Configure** page:
   - Enter the **Site URL**: `http://YOUR_SERVER_IP`
   - Click **Run Installation →**

5. You'll see a success screen with green ✓ checkmarks.

6. Click **Open LIS Portal →** to verify the portal loads.

---

## Step 4 — Delete the installer ⚠

**Immediately** after successful install, delete `public/install.php` via File Manager.  
It must not stay on the server.

---

## Step 5 — Set up the cron job (automatic BUKA/TUTUP schedule)

1. cPanel → **Cron Jobs**
2. Set timing to **Every Minute** (`* * * * *`)
3. Command (replace `USERNAME` with your actual cPanel username):
   ```
   /usr/local/bin/php /home/USERNAME/public_html/lis-portal/artisan schedule:run >> /dev/null 2>&1
   ```
   > If `/usr/local/bin/php` doesn't work, try `/usr/bin/php82` or `/opt/cpanel/ea-php82/root/usr/bin/php`

This makes the smart lane automatically open/close at the scheduled times.

---

## Accessing the portal

After setup, open:
```
http://YOUR_SERVER_IP/lis-portal/public/
```

Or to remove the `/public/` from the URL, go to Step 6.

---

## Step 6 (Optional) — Clean URL without /public/

If you want `http://YOUR_SERVER_IP/lis-portal/` (without `/public/`) to work:

The `.htaccess` file already included in the package handles this.  
It is placed at `public_html/lis-portal/.htaccess` and rewrites all requests through `public/`.

Just make sure `mod_rewrite` is enabled on your cPanel server (it usually is).  
Then access the portal at `http://YOUR_SERVER_IP/lis-portal/`.

---

## Troubleshooting

| Symptom | Fix |
|---|---|
| Blank white page / 500 error | In File Manager open `lis-portal/.env` → set `APP_DEBUG=true`, reload, read the error |
| "Class not found" / autoload errors | `vendor/` folder is incomplete — re-upload it from the zip |
| "unable to open database" | `database/` folder permissions are wrong — set to 755, file to 644 |
| 404 on all pages | `mod_rewrite` is off or `.htaccess` was not uploaded — check both `.htaccess` files exist |
| Installer shows vendor/ missing | vendor/ was not included — contact support or re-download the zip |
| Cron not running | Find correct PHP path: in cPanel Terminal run `which php82` or `which php` |
| Storage/logs not writing | `storage/` and all subdirectories must be 755 — apply recursively |

---

## File structure after install

```
public_html/lis-portal/
├── .env                      ← written by installer (has APP_KEY)
├── .htaccess                 ← clean URL rewrite
├── artisan
├── bootstrap/cache/          ← must be writable
├── database/
│   └── database.sqlite       ← all your data lives here
├── public/
│   ├── .htaccess
│   └── index.php             ← Laravel entry point
├── storage/                  ← logs, sessions, cache (must be writable)
└── vendor/                   ← PHP dependencies (included in zip)
```
