# Installing on atcomart.com (cPanel shared hosting)

Use **`seo-platform-hosting-upload.zip`**. It already contains `vendor/` and the built CSS/JS, so you need neither Composer nor Node on the server. The platform runs on MySQL only, with no Redis needed: one cron job runs the scheduler, and that starts the background workers each minute.

Install it on a **subdomain** such as `seo.atcomart.com` so it never touches the main atcomart.com website.

## 1. Check PHP
cPanel → **MultiPHP Manager** → set the subdomain (or the account) to **PHP 8.3 or 8.4**.
cPanel → **Select PHP Version → Extensions** (if offered): enable `pdo_mysql, mbstring, xml/dom, curl, gd, intl, zip, fileinfo, openssl, bcmath`.
Set `memory_limit` to at least 256M (512M is better) in **MultiPHP INI Editor**.

## 2. Create the database
cPanel → **MySQL Databases**:
1. Create a database, e.g. `atcomart_seo`.
2. Create a user, e.g. `atcomart_seo`, with a strong password.
3. Add the user to the database with **ALL PRIVILEGES**.

## 3. Upload the files
cPanel → **File Manager** → your home folder (the one that *contains* `public_html`, not inside it):
1. Upload `seo-platform-hosting-upload.zip` → right-click → **Extract**. You now have `/home/CPANELUSER/seo-platform/`.
2. Inside `seo-platform`, rename `.env.hosting.example` → `.env` (turn on "Show hidden files" in Settings).
3. Edit `.env`: set `APP_URL`, the `DB_*` values from step 2, the mail settings, and `SEO_OWNER_PASSWORD` (your first login password).
4. Make `seo-platform/storage` and `seo-platform/bootstrap/cache` writable (permissions 775; File Manager → Change Permissions → tick "recurse").

## 4. Point a subdomain at the app
cPanel → **Domains** (or Subdomains) → create `seo.atcomart.com` with **Document Root = `seo-platform/public`**.
Then cPanel → **SSL/TLS Status** → run AutoSSL so the subdomain gets HTTPS.

> If your host won't let a document root point outside `public_html`, extract into `public_html/seo-platform` instead and set the subdomain's document root to `public_html/seo-platform/public`. The included `.htaccess` keeps everything except `public/` unreachable.

## 5. Install: generate the key, create tables and your login
**With cPanel Terminal** (cPanel → Terminal):
```bash
cd ~/seo-platform
php artisan key:generate --force
php artisan migrate --force
php artisan db:seed --force
php artisan optimize
```
If `php` is an old version there, use the full path from MultiPHP, e.g. `/opt/cpanel/ea-php83/root/usr/bin/php`.

**Without Terminal:** cPanel → **Cron Jobs** → add a temporary job set to "Once per minute":
```
cd /home/CPANELUSER/seo-platform && /opt/cpanel/ea-php83/root/usr/bin/php artisan key:generate --force && /opt/cpanel/ea-php83/root/usr/bin/php artisan migrate --force && /opt/cpanel/ea-php83/root/usr/bin/php artisan db:seed --force && /opt/cpanel/ea-php83/root/usr/bin/php artisan optimize
```
Wait two minutes, check that `.env` now has an `APP_KEY=base64:…` line, then **delete this cron job** (the key must not be regenerated again).

Then remove the `SEO_OWNER_PASSWORD=` value from `.env`.

## 6. The one permanent cron job
cPanel → **Cron Jobs** → "Once Per Minute (* * * * *)":
```
cd /home/CPANELUSER/seo-platform && /opt/cpanel/ea-php83/root/usr/bin/php artisan schedule:run >> /dev/null 2>&1
```
This runs uptime checks, crawls, audits, alerts, reports and API syncs. Within two minutes, **System** in the app should show the scheduler and all queues green.

## 7. First login
Open `https://seo.atcomart.com` → log in as `arvind@intelliworkz.tech` with the password you set → change it under Profile.
Then: Settings → Branding (logo), Settings → Notifications, System → **Send test e-mail**, Team → activate your 4 team members, Websites → **Add website**.

## 8. External watchdog (do this; it's free)
Shared hosting is exactly where cron silently stops. Create a check at healthchecks.io (period 5 min, grace 15 min) and paste its ping URL in **Settings → Monitoring & alerts**. Also add an UptimeRobot keyword monitor on the secret **Status URL** shown there. If your host only allows cron every 15 minutes, set "Scheduler considered down after" to 20 minutes.

## 9. Conversion tracking and Google
Follow `docs/WHAT-YOU-NEED-TO-PROVIDE.md` (Google service account, access per client) and `docs/CONVERSION-TRACKING.md` (snippet for each client website).

## Phase 3 checks on shared hosting
- **Mobile page checks need Chromium**, which shared hosting cannot run. They show "unsupported" until you either move to a VPS or run `deploy/mobile-worker/server.mjs` on any small machine with Node 18+ and enter its URL and token in Settings → Site checks & workflow (see DEPLOYMENT.md → "Mobile rendering worker"). Everything else in phase 3 works on shared hosting.
- Domain expiry uses `https://rdap.org`. Some hosts block outgoing requests; the screen then shows the error and you can enter the date manually per website.
- Approved inquiry-form tests send a real (labelled) inquiry to the client. Ask the client before an Admin approves a form.

## Shared hosting limits (read this)
- Hosts usually cap CPU time and long processes. Keep **Max pages per crawl** around 300–500 and **Max crawls at the same time = 1** (already set in `.env`). Crawls run in short chunks, so a large site just takes longer.
- Uptime checks run at best once per minute, driven by cron.
- Back up from cPanel → **Backup** (database + home folder), or with JetBackup if your host provides it. Keep `.env`: its `APP_KEY` decrypts stored API keys.
- Once you have many sites, daily crawls, or 1,000+ page sites, move to a VPS (see `DEPLOYMENT.md`). Same code; just switch `.env` to Redis and Supervisor.

## Updating later
Upload the new zip, extract over `seo-platform` (keep your `.env` and `storage/`), then run `php artisan migrate --force && php artisan optimize` (via Terminal or a one-time cron as in step 5).

## Troubleshooting
| Symptom | Fix |
|---|---|
| 500 error on first visit | `APP_KEY` missing (step 5) or `storage` not writable; see `storage/logs/laravel-*.log` |
| "Scheduler has not run" on System page | Cron line wrong, or the PHP path points to an old PHP version |
| Crawl stuck at "queued" | Same cron issue; or the host kills processes, so lower pages per crawl |
| No e-mails | Check the mail settings in `.env`, then System → Send test e-mail and read the e-mail log there |
| Page looks unstyled | The document root must be `seo-platform/public` |
