# 🎯 cPanel Node.js App Configuration Guide

Perfect! You have cPanel with Node.js support. Here's exactly what to enter:

---

## 📋 **Configuration Values for cPanel Node.js App**

### **1. Node.js version**
```
18.x or higher
```
**Choose:** The latest available (18.x, 19.x, 20.x, or 21.x)

---

### **2. Application mode**
```
Production
```

---

### **3. Application root**
```
/home/your_cpanel_username/public_html
```

**Example:**
- If your cPanel username is `rebrand123`
- Then use: `/home/rebrand123/public_html`

**Or if in subfolder:**
```
/home/your_cpanel_username/public_html/rebrandly
```

---

### **4. Application URL**
```
https://rebrandlyai.com
```
**Or:**
```
https://rebrandlyai.com/
```
(Both work - with or without trailing slash)

---

### **5. Application startup file**
```
server.js
```

**Important:** I just created this file for you at:
`C:\Users\hp\Documents\rev1111111\server.js`

**You need to upload it** to your server!

---

## 📤 **BEFORE Clicking "Create" - Upload server.js**

### **Upload via cPanel File Manager:**

1. Go to **cPanel** → **File Manager**
2. Navigate to `public_html` (your app root)
3. Click **Upload**
4. Upload: `server.js` from your computer
5. **Verify** it's in the same folder as `package.json`

**File structure should be:**
```
public_html/
├── server.js          ← Upload this!
├── package.json
├── next.config.mjs
├── .env
├── app/
├── components/
└── ...
```

---

## ⚙️ **Environment Variables (Important!)**

After creating the app, you need to add environment variables:

### **In cPanel Node.js App Settings:**

Click **"Edit"** on your app, then scroll to **Environment Variables** section.

**Add these variables:**

| Variable Name | Value |
|--------------|-------|
| `NODE_ENV` | `production` |
| `NEXT_PUBLIC_APP_URL` | `https://rebrandlyai.com` |
| `MYSQL_HOST` | `localhost` |
| `MYSQL_PORT` | `3306` |
| `MYSQL_USER` | Your database user |
| `MYSQL_PASSWORD` | Your database password |
| `MYSQL_DATABASE` | Your database name |
| `SMTP_HOST` | `business187.web-hosting.com` |
| `SMTP_PORT` | `465` |
| `SMTP_SECURE` | `true` |
| `SMTP_USER` | `noreply@rebrandlyai.com` |
| `SMTP_PASS` | `198100@@@@198100@@@@` |
| `SMTP_FROM_EMAIL` | `noreply@rebrandlyai.com` |
| `SMTP_FROM_NAME` | `Rebrandly AI` |
| `GROQ_API_KEY` | `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` |
| `SESSION_SECRET` | (from your .env file) |
| `STRIPE_SECRET_KEY` | (your Stripe key) |
| `NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY` | (your Stripe public key) |

**Or:** If cPanel supports `.env` files, your existing `.env` file should work automatically.

---

## 🚀 **Step-by-Step Setup Process**

### **Step 1: Upload server.js**
- Upload `server.js` to your app root folder

### **Step 2: Create Node.js App in cPanel**
1. Go to **cPanel** → **Setup Node.js App**
2. Click **Create Application**
3. Fill in the values above
4. Click **Create**

### **Step 3: Install Dependencies**
After creating the app, cPanel will show a command like:
```bash
source /home/username/nodevenv/public_html/18/bin/activate && cd /home/username/public_html
```

**Run these commands in cPanel Terminal:**
```bash
# Activate Node.js environment (copy from cPanel)
source /home/username/nodevenv/public_html/18/bin/activate

# Navigate to app directory
cd /home/username/public_html

# Install dependencies
npm install

# Build the application
npm run build
```

### **Step 4: Start the Application**
1. Go back to **Setup Node.js App**
2. Find your app in the list
3. Click **Start App** button
4. Status should change to **Running**

### **Step 5: Test Your App**
Visit: `https://rebrandlyai.com`

You should see your Rebrandly AI homepage!

---

## 🔧 **Troubleshooting**

### **"Application failed to start"**

**Check logs:**
1. In cPanel Node.js App settings
2. Click **Edit** on your app
3. Scroll down to **Log** section
4. Read error messages

**Common issues:**
- `server.js` not uploaded
- Dependencies not installed (`npm install` not run)
- App not built (`npm run build` not run)
- Wrong application root path
- Missing environment variables

---

### **"Cannot find module 'next'"**

**Solution:**
```bash
# In cPanel Terminal
source /home/username/nodevenv/public_html/18/bin/activate
cd /home/username/public_html
npm install
```

---

### **"Port already in use"**

**Solution:**
- Stop the app in cPanel
- Wait 10 seconds
- Start it again

---

### **"Database connection failed"**

**Check:**
- Environment variables are set correctly
- Database credentials match your MySQL database
- Database user has ALL PRIVILEGES

---

## ✅ **Quick Checklist**

Before starting the app:

- [ ] `server.js` uploaded to app root
- [ ] All files uploaded (app, components, lib, etc.)
- [ ] `.env` file uploaded with correct values
- [ ] `/install` folder deleted
- [ ] Node.js app created in cPanel
- [ ] Environment variables added (if needed)
- [ ] `npm install` completed
- [ ] `npm run build` completed
- [ ] App started in cPanel
- [ ] Visit `https://rebrandlyai.com` to test

---

## 📊 **Expected Result**

When everything is configured correctly:

1. **cPanel shows:** App status = **Running**
2. **Browser shows:** Your Rebrandly AI homepage
3. **Sign up works:** Can create account
4. **Email works:** Verification email received
5. **Login works:** Can access dashboard

---

## 🎉 **Summary**

**Configuration values:**
- Node.js version: `18.x`
- Application mode: `Production`
- Application root: `/home/username/public_html`
- Application URL: `https://rebrandlyai.com`
- Application startup file: `server.js`

**Upload `server.js` first, then create the app!**

---

**Need help?** Check the logs in cPanel Node.js App settings for specific error messages.
