# cPanel deploy — split layout (recommended)

> **CloudLinux / shared cPanel:** use [DEPLOY-SPLIT.md](../../DEPLOY-SPLIT.md) — Laravel in `public_html`, Node in `wa-node`, startup **`app.js`**.

Standalone WhatsApp Node for CPS Laravel. Upload **only this folder** to `/home/user/wa-node` on cPanel.

## Folder layout on server

```text
/home/user/wa-node/
├── app.js              ← startup file
├── sessionManager.js
├── package.json
├── engines/
├── lib/
├── routes/
├── socket/
└── paytm/
```

**No** Laravel files. **No** `node_modules` upload. **No** `server.js` (that is for single-repo deploy only).

## Requirements

- cPanel **Setup Node.js App** (CloudLinux Node.js Selector)
- Node.js **18+**
- Writable folder for `baileys_credentials/`

## Steps

1. **Clean** target folder — delete any old `node_modules/`, Laravel `public/`, `Modules/`, etc.

2. **Upload** all files from this directory **except** `node_modules/`

3. **Use cPanel `package.json`** — on shared hosting, full `package.json` fails (puppeteer / whatsapp-web.js). Either:
   - Rename [`package.cpanel.json`](package.cpanel.json) → `package.json` before upload, **or**
   - On server, replace `package.json` contents with `package.cpanel.json` (Baileys 7 only)

   **Do not** install `puppeteer` or `whatsapp-web.js` on cPanel — `npm error code 1` / hang.

4. **Setup Node.js App**:

| Setting | Value |
|---------|-------|
| Application root | `/home/user/wa-node` |
| Application URL | `wa-node.yourdomain.com` |
| Startup file | **`app.js`** |
| Node version | 18 or 20 |

4. **Environment variables**:

```env
WA_ENGINE=baileys7
HOST=0.0.0.0
DATA_DIR=/home/user/wa-node
```

5. **Run NPM Install** → **Restart**

6. **Domains:** do not map the subdomain to PHP/Laravel document root — Node.js App must own the URL.

7. **Laravel** (separate `public_html` install): Owner → Settings → WhatsApp:

```
node_base_url = https://wa-node.yourdomain.com
```

8. **Test**:

```bash
curl https://wa-node.yourdomain.com/health
```

Expect: `"ok": true`, `"engine": "baileys7"`

## CloudLinux note

Never upload a physical `node_modules/` folder. The selector creates a symlink to a virtual environment. If NPM Install fails with a `node_modules` conflict error, delete the uploaded folder and retry.

## Auth persistence

Sessions: `baileys_credentials/session-{api_key}/` under `DATA_DIR`. Keep across redeploys unless customers should re-scan QR.

## Do NOT use webjs on cPanel

`WA_ENGINE=webjs` needs Chromium — local PC or VPS only.

## API (Laravel WhatsAppNodeClient)

| Method | Path |
|--------|------|
| GET | `/health` |
| GET | `/start/:sessionId` |
| GET | `/send-message` |
| POST | `/send-media` |
| GET | `/logout/:sessionId` |

Full split deploy guide: [DEPLOY-SPLIT.md](../../DEPLOY-SPLIT.md)
