# Epic Travel & Expeditions - cPanel PHP Installation Guide

## 📋 Overview
This guide will help you install Epic Travel & Expeditions on standard cPanel hosting using only FTP or File Manager - no SSH, Python, or root access required!

## ✅ Requirements
- cPanel hosting account
- PHP 7.4 or higher
- MySQL 5.7+ or MariaDB 10.3+
- At least 100MB disk space
- FTP client (FileZilla, WinSCP) OR cPanel File Manager access

## 📦 Package Contents
```
epic-travel-php/
├── frontend/              # React production build
│   ├── index.html
│   ├── .htaccess
│   └── static/
├── api/                   # PHP backend
│   ├── index.php         # Main API router
│   ├── config.php        # Configuration file
│   ├── .htaccess
│   ├── setup_password.php
│   ├── includes/
│   └── api/
├── database_schema.sql    # MySQL database structure
└── INSTALLATION.md        # This file
```

## 🚀 Installation Steps

### Step 1: Create MySQL Database

1. **Log into cPanel**
2. **Go to "MySQL® Databases"**
3. **Create New Database:**
   - Database name: `epictravel` (or your choice)
   - Click "Create Database"
   
4. **Create Database User:**
   - Username: Choose a username
   - Password: Generate a strong password
   - Click "Create User"
   
5. **Add User to Database:**
   - Select your user
   - Select your database
   - Grant **ALL PRIVILEGES**
   - Click "Make Changes"

6. **Note Down:**
   - Database name: `username_epictravel`
   - Username: `username_dbuser`
   - Password: `your_password`
   - Host: `localhost`

### Step 2: Import Database Schema

**Option A: Using phpMyAdmin**
1. Go to cPanel → phpMyAdmin
2. Select your database from the left sidebar
3. Click "Import" tab
4. Click "Choose File" and select `database_schema.sql`
5. Click "Go" at the bottom
6. Wait for "Import has been successfully finished" message

**Option B: Using MySQL Databases Tool**
1. Go to cPanel → MySQL Databases
2. Find "Run SQL on Database" section (if available)
3. Copy contents of `database_schema.sql`
4. Paste and execute

### Step 3: Upload Files via FTP

**Using FTP Client (FileZilla, WinSCP, etc.):**

1. **Connect to your server:**
   - Host: `ftp.yourdomain.com` (or your server IP)
   - Username: Your cPanel username
   - Password: Your cPanel password
   - Port: 21 (or 22 for SFTP if available)

2. **Upload Frontend:**
   - Navigate to `public_html/` (or your domain's folder)
   - Upload all files from `frontend/` folder
   - Make sure `.htaccess` is uploaded

3. **Upload Backend:**
   - Create folder: `public_html/api/`
   - Upload all files from `api/` folder to `public_html/api/`
   - Make sure `.htaccess` is uploaded
   - Create folder: `public_html/api/uploads/` (empty folder for image uploads)

### Step 3 (Alternative): Upload via File Manager

**Using cPanel File Manager:**

1. **Open File Manager** in cPanel
2. **Navigate to** `public_html/`
3. **Upload Frontend:**
   - Click "Upload" button
   - Select all files from `frontend/` folder
   - Wait for upload to complete
4. **Create API Folder:**
   - Click "New Folder"
   - Name it `api`
5. **Navigate to** `public_html/api/`
6. **Upload Backend:**
   - Click "Upload"
   - Select all files from `api/` folder
7. **Create Uploads Folder:**
   - Inside `/api/`, click "New Folder"
   - Name it `uploads`
   - Right-click → "Change Permissions" → Set to `755`

### Step 4: Configure Database Connection

1. **Navigate to** `public_html/api/`
2. **Edit** `config.php` (right-click → Edit or Code Editor)
3. **Update these lines:**
   ```php
   define('DB_HOST', 'localhost');
   define('DB_NAME', 'username_epictravel');  // Your database name
   define('DB_USER', 'username_dbuser');      // Your database user
   define('DB_PASS', 'your_password');        // Your database password
   ```

4. **Generate JWT Secret Key:**
   - Visit: https://www.grc.com/passwords.htm
   - Copy the "63 random alpha-numeric characters" key
   - Update in config.php:
   ```php
   define('JWT_SECRET_KEY', 'paste_your_generated_key_here');
   ```

5. **Update CORS Origin:**
   ```php
   define('ALLOWED_ORIGINS', 'https://yourdomain.com');
   ```

6. **Save the file**

### Step 5: Setup Admin Password

**Method A: Using Browser (Recommended)**

1. Visit: `https://yourdomain.com/api/setup_password.php`
2. Enter your desired admin password (e.g., `Joker1974!!!`)
3. Check "Update password in database"
4. Click "Generate Hash"
5. Verify success message
6. **IMPORTANT:** Delete `setup_password.php` file immediately

**Method B: Manual Database Update**

1. Go to phpMyAdmin
2. Select your database
3. Find `admin_users` table
4. Click "Edit" (pencil icon) for the admin row
5. In `password_hash` field, paste the generated hash
6. Click "Go"

### Step 6: Set Folder Permissions

**Via File Manager:**
1. Right-click `api/uploads/` folder
2. Select "Change Permissions"
3. Set to `755` (or `775` if needed)
4. Click "Change Permissions"

**Via FTP Client:**
1. Right-click `api/uploads/` folder
2. File Permissions → `755`
3. Apply

### Step 7: Test Installation

1. **Test Backend API:**
   - Visit: `https://yourdomain.com/api/`
   - Should see: `{"message":"Epic Travel API is running","status":"healthy"}`

2. **Test Frontend:**
   - Visit: `https://yourdomain.com`
   - Should see the Epic Travel homepage

3. **Test Admin Login:**
   - Visit: `https://yourdomain.com/admin`
   - Email: `admin@epictravel.com`
   - Password: `Joker1974!!!` (or your chosen password)

## 🔧 Troubleshooting

### "Internal Server Error" (500)

**Check PHP Version:**
1. cPanel → MultiPHP Manager
2. Ensure PHP 7.4 or higher is selected
3. Apply changes

**Check .htaccess:**
1. Ensure `.htaccess` files are uploaded
2. Check if they're hidden (Show Hidden Files in File Manager)

**Check Permissions:**
- Folders: `755`
- Files: `644`
- uploads/ folder: `755` or `775`

### Database Connection Failed

1. **Verify credentials in config.php**
2. **Check user privileges in cPanel → MySQL Databases**
3. **Try localhost vs 127.0.0.1 in DB_HOST**
4. **Contact hosting support if issue persists**

### Frontend Shows Blank Page

1. **Check browser console (F12) for errors**
2. **Verify API is working** (`/api/` endpoint)
3. **Check `.htaccess` in public_html**
4. **Clear browser cache (Ctrl+Shift+Del)**

### CORS Errors

1. **Update ALLOWED_ORIGINS in config.php**
2. **Use your actual domain (with https://)**
3. **Restart by saving config.php again**

### Can't Upload Images

1. **Check uploads/ folder exists**
2. **Set permissions to 755 or 775**
3. **Check PHP upload_max_filesize**:
   - cPanel → MultiPHP INI Editor
   - Increase upload_max_filesize to 10M
   - Increase post_max_size to 10M

### Admin Login Not Working

1. **Verify password was set correctly**
2. **Run setup_password.php again**
3. **Check admin_users table in database**
4. **Clear browser cookies**

## 📁 File Structure After Installation

```
public_html/
├── index.html              # Frontend entry point
├── .htaccess              # Frontend routing
├── static/                # CSS, JS files
│   ├── css/
│   └── js/
├── api/                   # Backend
│   ├── index.php         # API router
│   ├── config.php        # Configuration
│   ├── .htaccess         # API routing
│   ├── includes/         # Core files
│   │   ├── database.php
│   │   ├── jwt.php
│   │   └── functions.php
│   ├── api/              # Endpoints
│   │   ├── auth.php
│   │   ├── destinations.php
│   │   ├── specials.php
│   │   ├── contact.php
│   │   ├── newsletter.php
│   │   └── upload.php
│   └── uploads/          # Image uploads (empty)
└── favicon.ico
```

## 🔐 Security Checklist

After installation:
- [ ] Changed admin password from default
- [ ] Updated JWT_SECRET_KEY in config.php
- [ ] Deleted setup_password.php
- [ ] Set correct folder permissions
- [ ] Enabled SSL certificate (HTTPS)
- [ ] Updated ALLOWED_ORIGINS to your domain
- [ ] Verified config.php is not web-accessible
- [ ] Regular backups scheduled

## 🔄 Updating the Application

1. **Backup first!**
   - Download current files via FTP
   - Export database via phpMyAdmin

2. **Upload new files:**
   - Don't overwrite `config.php`
   - Upload updated files only

3. **Run database migrations (if any)**

4. **Test thoroughly**

## 📞 Support

**Application:** Epic Travel & Expeditions
**Contact:** advisor@epictravelexpeditions.com
**Phone:** +1 (817) 266-2022

**For Hosting Issues:**
- Contact your hosting provider's support
- Share error logs from cPanel → Error Logs

**Common Hosting Providers with cPanel:**
- Bluehost, HostGator, SiteGround, A2 Hosting, InMotion
- GoDaddy, Namecheap, DreamHost

## ✨ Success!

If everything is working:
1. Visit your website
2. Browse destinations
3. Try the contact form
4. Subscribe to newsletter
5. Login to admin panel
6. Add/edit destinations

**Congratulations! Your Epic Travel website is now live! 🎉**

---

**Next Steps:**
- Customize destination content
- Add your own images
- Update contact information
- Set up email forwarding for contact forms
- Enable SSL certificate for HTTPS
- Submit to search engines

Need help? Email us at advisor@epictravelexpeditions.com
