# Deploying NTPPA CMS on cPanel

Plain PHP + MySQL — no Composer, no Node, no build step. About 15 minutes.

> ### ▶ This copy is pre-configured for `https://clients.expertaims.in/ntppa/`
> - `app/config.php` already has `base_url => '/ntppa'` and the live URL — you only fill in the **3 database values**.
> - `.htaccess` already has `RewriteBase /ntppa/`.
> - **Where to put the files:** in cPanel create the subdomain **`clients`** (→ `clients.expertaims.in`), note its Document Root, then create a folder **`ntppa`** inside it and upload the files there, so `index.php` ends up at `…/clients.expertaims.in/ntppa/index.php`.
> - After DB import + config, browse to **`https://clients.expertaims.in/ntppa/admin/setup.php`**.
> - Moving to the real domain root later? set `base_url => ''` and `RewriteBase /`.

---

## 1. Create the database (cPanel → **MySQL® Databases**)

1. **Create New Database** → name it e.g. `ntppa` → it becomes `youracct_ntppa`. Note the full name.
2. **Add New User** → e.g. `ntppa` → set a strong password → **Create User**. Note `youracct_ntppa` + password.
3. Under **Add User To Database**, add that user to that database → tick **ALL PRIVILEGES** → **Make Changes**.

You now have three values: **DB name**, **DB user**, **DB password** (host is almost always `localhost`).

## 2. Import the tables + starter content (cPanel → **phpMyAdmin**)

1. Open **phpMyAdmin**, click your `youracct_ntppa` database in the left list.
2. Go to the **Import** tab → **Choose File** → select **`database/schema.sql`** from this project → **Go**.
3. You should see the tables `users, pages, sections, posts, media, settings` created and seeded.

## 3. Upload the files (cPanel → **File Manager**)

1. Zip the **contents** of the `ntppa-cms` folder (so `index.php` is at the top of the zip, *not* inside a `ntppa-cms/` subfolder).
2. In File Manager, open **`public_html`** (or a subfolder like `public_html/site`), **Upload** the zip, then **Extract** it.
3. After extraction the web root should contain: `index.php`, `.htaccess`, `admin/`, `app/`, `assets/`, `images/`, `uploads/`, `database/`.

> Installing in a **subfolder**? Edit `.htaccess` (uncomment `RewriteBase /site/`) and set `'base_url' => '/site'` in step 4.

## 4. Add your database details

1. In File Manager, go to **`app/`**, copy **`config.sample.php`** to **`config.php`** (right-click → Copy).
2. Edit `app/config.php` and fill in the three values from step 1:
   ```php
   'db_host' => 'localhost',
   'db_name' => 'youracct_ntppa',
   'db_user' => 'youracct_ntppa',
   'db_pass' => 'your-db-password',
   'base_url' => '',   // '' at domain root, or '/site' if in a subfolder
   ```

## 5. Make uploads writable

- Right-click the **`uploads/`** folder → **Change Permissions** → set to **755** (or **775** if 755 fails). This lets the client upload images.

## 6. Create your admin login

1. Visit **`https://yourdomain.com/admin/setup.php`**.
2. Enter a name, email, and password (≥ 8 chars) → **Create account**.
3. **Delete `admin/setup.php`** afterwards (File Manager → right-click → Delete). Important for security.

## 7. Log in and edit

- Go to **`https://yourdomain.com/admin/`** and sign in.
- **Pages** → click any page → edit its **Sections**, **Banner**, and **SEO & Meta** (with live Google preview).
- **Blog Posts**, **Media Library**, **Settings** (site name, phone, email, address, socials).
- The public site is at **`https://yourdomain.com/`** — every change publishes instantly.

---

## Going live on the real domain

The public pages are served from the database and reuse the site's own `assets/style.css`,
`assets/common.js` and `images/` — identical look to the revamp. When ready, point the domain's
document root here (or upload into the live `public_html`) and update `canonical` URLs in
**Settings** / each page's SEO tab.

## Troubleshooting

| Symptom | Fix |
|---|---|
| *"Setup needed: copy config.sample.php…"* | You skipped step 4 — create `app/config.php`. |
| *Database connection failed* | Re-check DB name/user/password in `app/config.php`; confirm the user is attached to the DB with ALL PRIVILEGES. |
| Pages show but **CSS is missing** | `base_url` is wrong. At domain root it must be `''`; in a subfolder set it to `/subfolder` and match `RewriteBase`. |
| **404 on every page** except home | `mod_rewrite`/`.htaccess` not active — most cPanel/LiteSpeed hosts allow it by default; contact host if `AllowOverride` is off. |
| **Image upload fails** | `uploads/` isn't writable — set permissions to 775 (step 5). |
| Blank white page | Temporarily add `ini_set('display_errors',1);` at the top of `index.php` to see the error, then remove it. |

## Security checklist

- [ ] Deleted `admin/setup.php` after creating your account.
- [ ] `app/config.php` has real credentials (it's blocked from the web by `app/.htaccess`).
- [ ] Strong admin password.
- [ ] Site served over **HTTPS** (cPanel → SSL/TLS or AutoSSL).
