# JournalSphere CMS — cPanel Installation Guide

**Requirements:** cPanel shared hosting · PHP 8.1+ (extensions: pdo_mysql, mbstring, fileinfo, openssl; curl recommended) · MySQL 5.7+/MariaDB 10.3+ · SSL certificate (AutoSSL / Let's Encrypt).

## 1. Upload the files
1. cPanel → **MultiPHP Manager**: set the domain to **PHP 8.1 or newer**.
2. cPanel → **File Manager** → open `public_html` (or the sub-domain / sub-folder folder, e.g. `public_html/journal`).
3. **Upload** `journalsphere-cms.zip` and **Extract** it. Make sure `index.php` sits directly in the target folder (move files up if they extracted into a `journalsphere/` sub-folder).
4. Make these folders writable (permission `755`; use `775` only if uploads fail): `config/`, `storage/`, `storage/uploads/`, `storage/backups/`, `assets/uploads/`.

## 2. Create the database
1. cPanel → **MySQL® Databases** → create a database (e.g. `cpuser_journal`).
2. Create a database user with a strong password and **Add User To Database → ALL PRIVILEGES**.
3. Note the full names (cPanel prefixes them with your account name).

## 3. Run the web installer
1. Browse to `https://your-domain/install/`.
2. All requirement rows should show **OK**.
3. Enter the DB host (`localhost`), DB name/user/password, the site URL, and create the **Super Administrator** account.
4. Click **Install**. The installer imports `database/journalsphere.sql`, writes `config/config.php`, and locks itself.
5. **Delete the `install/` folder** (File Manager → Delete).

### Manual alternative (no installer)
1. phpMyAdmin → select the DB → **Import** → `database/journalsphere.sql`.
2. Copy `config/config.sample.php` to `config/config.php` and edit it.
3. Create the admin: cPanel → *Terminal* (or SSH): `php tools/create_admin.php "Your Name" you@example.com 'StrongPass1'`.

## 4. First login & configuration
1. Sign in at `/login.php` → Super Admin dashboard.
2. **Journals** → edit the sample journal (title, ISSN/eISSN, publisher, scope, policies, guidelines, logo) or create more journals.
3. **Editorial Board** → add the Editor-in-Chief, Associate / Section / Review editors.
4. **Users** → create Editors / Journal Admins and assign them to journals (tick the journals).
5. **Issues** → create Volume/Issue records.
6. **Settings** → configure SMTP, CrossRef, ORCID (see below).

## 5. Email (SMTP) setup
cPanel → **Email Accounts** → create `noreply@your-domain`. In **Settings → Email (SMTP)**:

| Field | Value |
|---|---|
| Host | `mail.your-domain.com` (or the server name shown in *Email Accounts → Connect Devices*) |
| Port / Encryption | `465` + SSL/TLS, or `587` + STARTTLS |
| Username | full email address |
| Password | the mailbox password |
| From address | `noreply@your-domain.com` |

Press **Send test** to verify. Add SPF/DKIM (cPanel → *Email Deliverability*) so messages are not flagged as spam. If SMTP host is left empty the system uses PHP `mail()`.

## 6. DOI (CrossRef), ORCID
* **CrossRef:** Settings → *DOI / CrossRef* → enter your DOI prefix, CrossRef login & password, depositor details. Keep **test mode** ticked until you have verified a deposit on `test.crossref.org`. Then: *DOI Management* → Generate DOI → Register.
* **ORCID:** register a public API client at orcid.org/developer-tools; set the redirect URI shown in Settings (`…/orcid_callback.php`); paste Client ID/Secret. Users then see **Connect ORCID** in their profile.

## 7. Backups
* **Manual:** Admin → *Backups* → *Create backup now* → download the `.sql.gz`.
* **Automatic:** cPanel → **Cron Jobs** → daily `0 2 * * *`:
  `/usr/local/bin/php /home/CPUSER/public_html/cron/backup.php` (keeps the newest 14).
* Also back up the uploaded files (`storage/uploads`) with cPanel → *Backup* or *JetBackup*, and copy backups off-server.
* Reviewer reminders (optional cron, daily): `/usr/local/bin/php /home/CPUSER/public_html/cron/reminders.php`

## 8. Security checklist
* ✔ `install/` deleted. ✔ HTTPS forced (root `.htaccess`). ✔ `config/`, `includes/`, `database/`, `storage/`, `cron/`, `tools/` are blocked by `.htaccess`.
* **Best practice:** move uploads outside the web root — create `/home/CPUSER/journal_storage/{uploads,backups}` and add `'storage_path' => '/home/CPUSER/journal_storage',` to `config/config.php`.
* Set `config/config.php` permission to `640`. Keep `'debug' => false`.
* Use strong passwords for Super Admin; review **Activity Log** periodically.
* Keep PHP updated through MultiPHP Manager.

## 9. Troubleshooting
| Symptom | Fix |
|---|---|
| Blank page / HTTP 500 | Set `'debug' => true` temporarily in `config/config.php`; check cPanel *Errors* log. |
| Uploads fail | Raise `upload_max_filesize` / `post_max_size` (MultiPHP INI Editor); `.user.ini` is included. |
| Emails not delivered | Use **Settings → Send test**; check mail log table shown below it. |
| Redirect loop on HTTPS | Behind a proxy/Cloudflare: ensure `X-Forwarded-Proto` is passed, or remove the HTTPS block in `.htaccess`. |
| Wrong links | Set `base_url` in `config/config.php`. |
