# cPanel installation guide

## 1. Preserve the existing website

1. In cPanel File Manager, create a full backup of the current document root.
2. Export the current database, if one exists.
3. Stage this release in a temporary subdomain or maintenance window before switching production traffic.
4. Do not delete unrelated existing files until the new release has passed the verification checklist.

## 2. Create the database

1. Open **MySQL Databases** in cPanel.
2. Create a database and database user.
3. Assign the user to the database with all privileges.
4. Note the cPanel-prefixed database name and username.

The installer imports `database/schema.sql`; manual phpMyAdmin import is also supported.

## 3. Upload the package

Recommended account layout:

```text
/home/CPANEL_USER/
├── database/
├── private/
└── public_html/
    ├── admin/
    ├── assets/
    ├── install/
    └── ...
```

Upload:

- `cpanel/public_html/*` into the domain document root.
- `cpanel/private` and `cpanel/database` one level above the document root as shown.

If you place private files inside a custom folder such as `/home/CPANEL_USER/adsolutions-platform/`, update the `$privateRoot` path in `public_html/_bootstrap.php` and the path expressions in `private/config/config.php`. The supplied configuration works without path changes when `private`, `database`, and `public_html` are siblings.

## 4. Configure the application

Edit `private/config/config.php`:

- Set `app.url` to `https://adsolutionsbangladesh.com`.
- Replace `APP_KEY` with a random 64-character hexadecimal value.
- Enter the database host, port, database, username, and password.
- Keep `app.debug` disabled in production.

Generate an application key in cPanel Terminal:

```bash
php -r "echo bin2hex(random_bytes(32)), PHP_EOL;"
```

Paste only the generated key into `app.key`. Never reuse a password as the application key.

Environment variables may be used instead of editing values directly. The supported names are listed in `.env.example`; the application does not parse `.env` files automatically.

## 5. Set permissions

Typical shared-hosting permissions:

- Directories: `0755`
- Public files: `0644`
- `private/storage`, `private/storage/logs`, and `private/storage/backups`: writable by the PHP user; prefer `0750`
- `public_html/uploads`: writable by the PHP user; prefer `0755`
- `private/config/config.php`: prefer `0640`

Do not use `0777`.

## 6. Run the installer

1. Open `https://adsolutionsbangladesh.com/install/`.
2. Enter the first Super Admin name, email, and a strong password.
3. Submit once. The installer imports the schema, creates the account with `password_hash()`, prepares storage, and writes `private/storage/installed.lock`.
4. Sign in at `https://adsolutionsbangladesh.com/admin`.
5. Remove `public_html/install/` after the first successful login.

No default administrator password is included.

## 7. Configure the domain

1. Enable AutoSSL or install a valid SSL certificate.
2. Confirm the document root points to `public_html`.
3. Confirm Apache rewrite rules are enabled.
4. If Cloudflare is used, select **Full (strict)** SSL and avoid a redirect loop by keeping the origin certificate valid.
5. Configure SPF, DKIM, and DMARC for the business email through cPanel Email Deliverability.

## 8. Verify production

- Load every public page on desktop and mobile.
- Test dark/light mode, mobile navigation, portfolio filters, animations, counters, map, WhatsApp, and back-to-top.
- Submit the contact, quote, and newsletter forms.
- Confirm records appear in the admin panel.
- Test each role with a non-production account.
- Upload an image, video, and PDF; confirm PHP execution is blocked in `/uploads`.
- Create a manual backup.
- Check `/robots.txt`, `/sitemap.xml`, canonical URLs, metadata, and structured data.
- Confirm unknown routes return the branded 404 page with HTTP 404.
- Confirm HTTP redirects to HTTPS and security headers are present.
- Run the CLI health check:

```bash
php private/scripts/health-check.php --database
```

## Rollback

If verification fails:

1. Put the site in maintenance mode through cPanel.
2. Restore the pre-deployment files.
3. Restore the pre-deployment database export.
4. Clear any server or Cloudflare cache.
5. Investigate in the staging copy before retrying.
