═══════════════════════════════════════════════════════════════ WASTE MANAGEMENT BACKEND - cPanel DEPLOYMENT STEPS ═══════════════════════════════════════════════════════════════ STEP 1: PREPARE THE BACKEND ──────────────────────────── 1. Copy the entire 'backend' folder to a safe location 2. The backend folder contains: ✓ All Laravel files ✓ Migrations (database structure) ✓ Controllers (API logic) ✓ Models (data structure) ✓ Routes (API endpoints) STEP 2: CREATE DATABASE IN cPANEL ────────────────────────────────── 1. Log into your cPanel account 2. Find "MySQL Databases" icon 3. Create a new database: - Database name: waste_management (or your choice) 4. Create a database user: - Username: (choose a username) - Password: (choose a strong password) 5. Add user to database: - Select the user - Select the database - Grant ALL PRIVILEGES STEP 3: UPLOAD FILES TO cPANEL ────────────────────────────── Option A - Using cPanel File Manager: 1. Compress the 'backend' folder into a ZIP file 2. Go to cPanel → File Manager 3. Navigate to public_html folder 4. Upload the ZIP file 5. Right-click and extract it Option B - Using FTP: 1. Use FileZilla or any FTP client 2. Connect to your hosting 3. Upload all files from 'backend' folder to public_html STEP 4: CONFIGURE ENVIRONMENT FILE ─────────────────────────────────── 1. In cPanel File Manager, navigate to the backend folder 2. Find the file '.env.production' 3. Rename it to '.env' 4. Edit the file and update these lines: APP_URL=https://yourdomain.com DB_DATABASE=your_database_name DB_USERNAME=your_database_username DB_PASSWORD=your_database_password 5. Save the file STEP 5: SET UP USING cPANEL TERMINAL (OR SSH) ────────────────────────────────────────────── 1. Open Terminal in cPanel (if available) or use SSH 2. Navigate to your backend folder: cd ~/public_html/backend 3. Install dependencies (if composer is available): composer install --optimize-autoloader --no-dev 4. Set permissions: chmod -R 755 storage bootstrap/cache 5. Generate application key: php artisan key:generate 6. Run database migrations: php artisan migrate --force 7. Seed initial data (creates admin, driver, etc.): php artisan db:seed 8. Optimize for production: php artisan config:cache php artisan route:cache STEP 6: CONFIGURE WEB ROOT ────────────────────────── Your Laravel backend needs to point to the 'public' folder. Option A - Subdomain Setup (Recommended): 1. Create a subdomain in cPanel (e.g., api.yourdomain.com) 2. Point the subdomain to: /home/username/public_html/backend/public Option B - Using .htaccess: The .htaccess file is already configured to redirect to public folder STEP 7: TEST THE API ──────────────────── Visit: https://yourdomain.com/api/test or: https://api.yourdomain.com/test (if using subdomain) You should see: { "success": true, "message": "API is working!", "version": "1.0.0" } STEP 8: UPDATE FLUTTER APP ─────────────────────────── In your Flutter app, edit: lib/api_constants.dart Change: final String url = "https://86cb7dddf33f.ngrok-free.app/api"; To: final String url = "https://yourdomain.com/api"; OR final String url = "https://api.yourdomain.com"; ═══════════════════════════════════════════════════════════════ DEFAULT TEST ACCOUNTS ═══════════════════════════════════════════════════════════════ After running db:seed, these accounts are available: Admin: Email: admin@wastemanagement.com Password: admin123 Login Master: Email: loginmaster@wastemanagement.com Password: master123 Driver: Email: driver@wastemanagement.com Password: driver123 Facility Owner: Email: owner@wastemanagement.com Password: owner123 ═══════════════════════════════════════════════════════════════ IMPORTANT SECURITY NOTES ═══════════════════════════════════════════════════════════════ 1. Change all default passwords after deployment 2. Keep APP_DEBUG=false in production 3. Use strong database passwords 4. Enable SSL/HTTPS certificate 5. Regularly update Laravel and dependencies 6. Keep .env file secure (never commit to git) ═══════════════════════════════════════════════════════════════ TROUBLESHOOTING ═══════════════════════════════════════════════════════════════ Problem: 500 Internal Server Error Solution: - Check file permissions (755 for folders, 644 for files) - Check .env configuration - View error logs: storage/logs/laravel.log Problem: Database Connection Error Solution: - Verify credentials in .env file - Ensure database and user exist - Check user has ALL PRIVILEGES on database Problem: API returns 404 Solution: - Check .htaccess file exists in public folder - Clear route cache: php artisan route:clear - Verify web root points to public folder Problem: CORS errors from Flutter app Solution: - Backend is configured to accept all origins - Check config/cors.php if issues persist ═══════════════════════════════════════════════════════════════ NEED HELP? ═══════════════════════════════════════════════════════════════ Check these logs: - Laravel: storage/logs/laravel.log - cPanel Error Logs (via cPanel) - PHP Error Logs (via cPanel) Common commands: - Clear cache: php artisan cache:clear - View logs: tail -f storage/logs/laravel.log ═══════════════════════════════════════════════════════════════