# Deploying Tina4 to cPanel

This file was generated by `tina4 deploy cpanel`. Pair it with the
`.htaccess` written alongside.

## What `tina4 deploy cpanel` produced

- `.htaccess` — Apache rewrite rules for clean URLs + entry-point
  routing + denial of `.env`/`*.sqlite`/`*.db`/`*.log`/`*.md` files.
- `deploy/CPANEL.md` — this file.

## Steps

1. **Upload the project** to your cPanel account's web root (typically
   `~/public_html/`). Use the cPanel File Manager, FTP, or a git pull
   via cPanel's terminal/SSH if available. Do NOT upload `.env` —
   create it directly on the server.

2. **Install dependencies** server-side:
   - PHP: `composer install --no-dev --optimize-autoloader`
   - Python: `pip install -r requirements.txt` (cPanel Python apps
     usually use a passenger_wsgi.py — see your host's docs)
   - Node: `npm ci --omit=dev`
   - Ruby: `bundle install --deployment --without development test`

3. **Create `.env`** on the server. Use cPanel's File Manager to add
   a `.env` file at the project root with at least:
   ```
   TINA4_DEBUG=false
   TINA4_DATABASE_URL=...
   TINA4_SECRET=<a-long-random-string>
   ```

4. **Set permissions** so the web user can read but not write
   sensitive files. cPanel default ownership is usually correct; if
   not: `chmod 644 .env` and `chmod 755 src/public/`.

5. **Database**: create one via cPanel → MySQL Databases (or PostgreSQL
   if available), then update `TINA4_DATABASE_URL` to match.

6. **Run migrations** once: `tina4 migrate` (if `tina4` is installed
   server-side) or your language's framework CLI directly.

7. **Visit your domain**. The framework should respond.

## Troubleshooting

- **500 Internal Server Error** → check cPanel's Error Log (Metrics →
  Errors). The most common cause is a missing `.env` value.
- **Routes 404 but `/` works** → `mod_rewrite` may be disabled. Ask
  cPanel support to enable it for your account.
- **Static files load but routes don't** → confirm `.htaccess` is
  present and not stripped by an editor adding `.txt`.

For more, see https://tina4.com/deployment.
