# Alpha Medicare - cPanel Deployment Guide

## Quick Start for cPanel Upload

### Option 1: Upload to Root Domain (e.g., alphamedicare.com)

1. **Upload all files** to your `public_html/` folder on cPanel
2. **The `public/` folder contents should be directly in `public_html/`**
   - OR point your domain to the `public/` subdirectory
3. **Run the deploy helper**: Visit `https://yourdomain.com/deploy.php` in your browser
4. **Delete `deploy.php` after successful deployment**

### Option 2: Upload to Subdomain (e.g., app.yourdomain.com)

1. **Upload all files** to `public_html/app/` (or your subdomain folder)
2. **Edit `public_html_index.php`** and uncomment the subdirectory path line
3. **Rename `public_html_index.php` to `index.php`** and place it in `public_html/`

### Option 3: Keep Laravel Structure (Advanced)

1. **Upload all project files** to a folder outside `public_html/` (e.g., `/home/username/alpha-medicare/`)
2. **Upload ONLY the contents of `public/` folder** to `public_html/`
3. **Edit `public_html/index.php`** and change:
   ```php
   $app = require_once __DIR__.'/../bootstrap/app.php';
   ```
   to:
   ```php
   $app = require_once __DIR__.'/../alpha-medicare/bootstrap/app.php';
   ```

## Database Setup

1. **Create a MySQL database** in cPanel
2. **Create a database user** and add it to the database with ALL PRIVILEGES
3. **Import the database** using phpMyAdmin:
   - File: `alphdkge_alpha.sql` (included in project root)
4. **Update `.env` file** with your database credentials:
   ```
   DB_HOST=localhost
   DB_DATABASE=your_cpanel_db_name
   DB_USERNAME=your_cpanel_db_user
   DB_PASSWORD=your_cpanel_db_password
   ```

## Required Configuration Changes

### 1. Update `.env` file

```env
APP_ENV=production
APP_DEBUG=false
APP_URL=https://yourdomain.com

DB_HOST=localhost
DB_DATABASE=your_cpanel_db_name
DB_USERNAME=your_cpanel_db_user
DB_PASSWORD=your_cpanel_db_password

# Use file driver for shared hosting
SESSION_DRIVER=file
CACHE_DRIVER=file
QUEUE_CONNECTION=sync
```

### 2. Set APP_KEY (if not already set)

```bash
php artisan key:generate
```

Or manually generate one and add to `.env`.

### 3. Set Permissions

```bash
chmod -R 755 storage
chmod -R 755 bootstrap/cache
chmod -R 644 .env
```

On some shared hosts, you may need:
```bash
chmod -R 775 storage
chmod -R 775 bootstrap/cache
```

### 4. Create Storage Link

If the symlink doesn't work on your host, copy the files:
```bash
cp -r storage/app/public/* public/storage/
```

Or use the deploy.php helper which handles this automatically.

## PHP Requirements

- **PHP Version**: 7.3 or higher (8.0-8.1 recommended)
- **Required Extensions**: mbstring, openssl, pdo, pdo_mysql, tokenizer, xml, ctype, json, bcmath

## Troubleshooting

### 500 Internal Server Error

1. Check `.env` file exists and is readable
2. Check `storage/` and `bootstrap/cache/` are writable
3. Check PHP version meets requirements
4. Check `.htaccess` is present in public folder

### Database Connection Error

1. Verify database credentials in `.env`
2. Ensure database exists and user has privileges
3. Try `DB_HOST=127.0.0.1` instead of `localhost`

### Missing Images/Files

1. Run `deploy.php` helper to create storage link
2. Or manually copy `storage/app/public/` contents to `public/storage/`

### CSS/JS Not Loading

1. Ensure `public/` folder contents are in web root
2. Check `.htaccess` is present and mod_rewrite is enabled
3. Clear browser cache

## Security Notes

- **Delete `deploy.php` after deployment**
- **Keep `.env` file outside web root if possible**
- **The `.htaccess` file already protects sensitive files**
- **Change default admin credentials immediately**

## Post-Deployment Checklist

- [ ] Website loads without errors
- [ ] Admin login works
- [ ] Database is connected and showing data
- [ ] Images are loading correctly
- [ ] Search functionality works
- [ ] Contact forms work (if email is configured)
- [ ] Delete deploy.php
- [ ] Change default passwords
- [ ] Set up SSL certificate (HTTPS)

## Support

For issues specific to this deployment, check the Laravel logs in `storage/logs/`
