# Skulitech ERP — cPanel deployment

## Server requirements
- PHP 8.1 or newer
- MySQL 8.0+ or MariaDB 10.4+
- PHP extensions: PDO MySQL, mbstring, fileinfo, JSON, OpenSSL, session, ZIP and GD
- Apache with `.htaccess` enabled
- HTTPS certificate enabled

## Fresh installation
1. In cPanel **MySQL Databases**, create a database and database user, then assign the user to the database with **ALL PRIVILEGES**.
2. Open phpMyAdmin, select that database, and import `database/schema/college_erp_current.sql`.
3. Copy `config/local.example.php` to `config/local.php`.
4. Edit `config/local.php` with the exact cPanel-prefixed database name, username, password and a long random `setup_key`.
5. Upload and extract this ZIP in the intended document root:
   - root domain: `public_html/`
   - subdomain: its document-root folder
   - subfolder: for example `public_html/erp/`
6. Ensure these folders are writable by PHP: `uploads/`, `exports/`, `storage/private/` and `storage/logs/`. Start with permissions `0755`; use `0775` only if your host requires group write access. Do not use `0777`.
7. Open `cpanel_setup.php`, enter the configured setup key, and create the first System Administrator. The setup page applies all pending database migrations before creating the account.
8. Delete `cpanel_setup.php` from the server immediately after the administrator is created.
9. Sign in through `login.php`, enable HTTPS redirection in cPanel, and test the ILO roster, placement, PDF and Excel export workflows.

## Upgrade of an existing installation
1. Back up the database and application files.
2. Preserve the existing `config/local.php` and uploaded files.
3. Extract the package over the application folder. This ZIP does not contain `config/local.php`, so an existing file is not overwritten.
4. In cPanel Terminal, run:
   `php bin/migrate.php`
5. Then run:
   `php bin/check_integrity.php`
6. Delete `cpanel_setup.php` when an administrator already exists.

## Important fixes in this package
- Correct root-domain and subfolder URL detection.
- Production database configuration no longer falls back to the MySQL root account.
- cPanel/phpMyAdmin schema no longer contains `CREATE DATABASE` or `USE`.
- The one-time browser setup applies all pending numbered migrations, so cPanel Terminal is not required for a fresh installation.
- Predictable bundled administrator credentials removed from fresh installs.
- Legacy unchanged default administrator is disabled by migration `20260730_020`.
- Import and upload directories block script execution.
- Root `.txt`, SQL, archive, log and configuration files are blocked from web access.
- Kenya application and database timezone defaults are configured.
