# 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/full-install.sql`** → **Go**. Done.

`full-install.sql` is the whole database in one file (tables + all 65 pages + 13 blog posts +
the Programs/About submenu pages). It is **safe to re-import any time**: your admin login,
media library and Settings are preserved — pages/sections/posts are reset to the packaged content.
On a brand-new database, open `admin/setup.php` once afterwards to create your login.

<details><summary>Advanced: the three individual files (only if you need them)</summary>

`schema.sql` (tables) → `content.sql` (site content) → `split-pages.sql` (submenu pages) →
`fix-gallery.sql` (gallery page as editable photo/video sections, mirroring the live
photo_gallery), in that order. If you re-import `content.sql`, always re-import
`split-pages.sql` and `fix-gallery.sql` right after it.
Note: re-importing `schema.sql` alone WIPES the users table (you'd need `admin/setup.php` again) —
prefer `full-install.sql`, which keeps logins.
</details>

## 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.

---

## Updating an EXISTING install (visual editor + team logins)

Already running an older copy? This release adds the **Word-style visual editor**,
**Import from Word (.docx)**, and **Team & Access** (multiple logins with per-area
privileges). Your content is safe — only code files change, plus one tiny column.

1. **Back up first** — phpMyAdmin → your DB → **Export**; and download the `ntppa/` folder.
2. **Upload the new code** — extract this package over your existing `ntppa/` folder,
   overwriting files. It does **not** touch your database, so every page/post you edited stays.
   *(`app/config.php` is excluded from the package, so your DB settings are untouched.)*
3. **Run the one-time migration** — phpMyAdmin → your DB → **Import** →
   **`database/migrate-users-perms.sql`** → **Go**. (Adds a `perms` column for team roles.
   If it says *"Duplicate column"*, it already ran — ignore.)
4. Done. Sign in → open any page section to see the new editor; open **Team & Access**
   (under **System** in the sidebar) to add editors and choose what each one can edit.

---

## 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).

---
## Upgrading an install that is already live

The simplest, can't-go-wrong path:

1. **Upload the whole zip and Extract over the existing files** (overwrite everything).
   Your `app/config.php` (database details) is NOT in the zip, so it survives untouched —
   same for anything the client uploaded into `uploads/`.
2. **phpMyAdmin → Import → `database/full-install.sql`**. Admin logins, the media library
   and Settings are preserved; all pages/sections/posts are reset to the packaged content.
3. Hard-refresh once (Ctrl/Cmd-Shift-R). From this build onward CSS/JS carry automatic
   version stamps, so browsers pick up future updates by themselves — no more stale styling.

What you get: the admin **Pages** screen becomes menu-grouped cards (mobile friendly),
each Programs/About submenu item is now its own editable page, Faculty/Press cards
have an **Add** box for creating new teacher/press pages, and old `#` links
(`about.html#faculty`, `programs.html#core`) auto-forward to the new pages.

---
### Admin shows "403 Forbidden" when opening/saving a page
Your host's **ModSecurity / WAF** is blocking the admin (rich HTML + video-embed
content trips generic rules). Fix in **cPanel → Security → ModSecurity™** →
toggle **Off** for the domain (or in **WHM → ModSecurity Tools**, whitelist the
rule ID shown in the hit log). Do **not** put `SecRuleEngine Off` in `.htaccess`
— most hosts disallow it there and the admin will return **500** instead.

---
## Update 2026-07-05 — Calendar page + section Enable/Disable radios

Matches the live site's `/calendar#calendar` layout. To apply on an
**already-live** install:

1. Upload **`admin/index.php`** (adds Enabled/Disabled radio buttons on every
   section — this is the show/hide-section control).
2. Upload **`assets/style.css`** (new `.cal-dd` dropdown + `.es-card` styles;
   optional but keeps styles in one place — the new sections also carry them inline).
3. phpMyAdmin → your DB → **SQL** → run **`database/fix-calendar-page.sql`**.

The Calendar page then has three independently toggleable sections
(Admin → Pages → Calendar): the collapsible **Recital & Examination Calendar**
dropdown, **Performance and Examinations**, and **Music Summer Programs 2026**.
Fresh installs get all of this from `split-pages.sql` automatically.

### Also 2026-07-05 — Programs & About overview pages: tile images
`/programs.html` and `/about.html` overview grids were text-only ("no images
displayed"). Fix on a live install: phpMyAdmin → SQL → run
**`database/fix-overview-pages.sql`** (nothing to upload — images are the live
site's own uploads, hotlinked, plus the packaged `images/` files). Safe to re-run.
