# How to Deploy to cPanel (Zero-Install Method)

Good news! We have upgraded the deployment process for **HorizonOne** so that it is now **completely pre-compiled and pre-installed (Zero-Install)**. 

The ZIP file generated now includes:
1. **Pre-compiled production assets** (`.next` folder).
2. **Pre-installed production dependencies** (`node_modules` pruned specifically for production ~40MB instead of 550MB+).
3. **Optimized production entry point** (`server.js`).

This means you **DO NOT** need to click "Run NPM Install" or run any compilation commands on your cPanel server. This bypasses all shared hosting resource limits (like RAM restrictions or CPU timeout limits) completely!

Here is how to get your application running in less than 2 minutes:

---

## Step 1: Clean Your cPanel Directory
1. Go to **cPanel > File Manager**.
2. Open the root directory of your application (e.g. `/home/username/newhorizonone.com` or your domain folder).
3. **Delete any old files and folders** inside it (like `.next`, `node_modules`, `app`, `lib`, etc.) to ensure a clean slate.

---

## Step 2: Upload and Extract the Zero-Install ZIP
1. Download your prepared Zero-Install deployment package by navigating to `/download` on your AI Studio preview app, or downloading directly from:
   `[Your App Preview URL]/api/download-zip`
2. In your **cPanel File Manager**, upload `cpanel-horizonone-deploy.zip` directly into your application root folder.
3. Right-click the uploaded ZIP file and click **Extract**. 
4. This extracts all necessary production-ready directories (like `node_modules`, `.next`, `public`) and configuration files directly into your root folder.

> 💡 **Note on `.htaccess`:** We have intentionally excluded `.htaccess` from the ZIP package. When you create or configure a Node.js app in cPanel, cPanel automatically generates its own `.htaccess` file containing unique home directory paths to load the app under Phusion Passenger. Overwriting this file would break your routing. Leaving cPanel's native `.htaccess` untouched ensures everything works perfectly.

---

## Step 3: Configure/Verify Setup Node.js App in cPanel
1. Go to **cPanel > Setup Node.js App**.
2. Create a new application (or edit your existing one) with these exact settings:
   - **Node.js version:** Select `18.x` or `20.x` (Recommended)
   - **Application mode:** `Production`
   - **Application root:** `newhorizonone.com` (Type *only* your folder name relative to your home directory. **DO NOT** write the full path like `/home/horizono/newhorizonone.com`!).
   - **Application startup file:** `server.js` (Type *exactly* `server.js`. **DO NOT** prefix it with your folder name!).
3. Click **Save** / **Create**.

### ⚠️ Common Setup Mistake: "package.json is required"
If you get a warning saying `"package.json file is required"`, this means your path inputs are incorrect:
* **The Application Root path must be relative to your home folder:** Enter only the folder name (e.g., `newhorizonone.com`).
* **The Application Startup file must be relative to the application root:** Enter only `server.js`.

---

## Step 4: Add Environment Variables & Start!
1. Under **Environment Variables** in Setup Node.js App, click **Add Variable** and configure:
   - Name: `GEMINI_API_KEY`
   - Value: `[Your Google Gemini API Key]` (Required to power the AI-driven contact form analysis)
2. **DO NOT run NPM Install!** (Everything is already pre-installed inside the extracted `node_modules` folder).
3. Click the **Start** (or **Restart**) button at the top of the Setup page.
4. Your high-performance website is now fully live and running!

---

## Why this is superior:
* **Zero Resource Usage during Deploy:** No compiling or installing on the cPanel side. This avoids standard shared hosting resource errors (e.g., `Exit 137 / Killed` due to memory limits).
* **Instant Activation:** Your app starts running immediately upon clicking "Start/Restart".
* **Extremely Lightweight:** By pruning devDependencies, the complete production ZIP package is only ~15-18MB!
