╔════════════════════════════════════════════════════════════════════╗ ║ WASTE MANAGEMENT BACKEND - CPANEL DEPLOYMENT GUIDE ║ ╚════════════════════════════════════════════════════════════════════╝ 📋 PREREQUISITES ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ✓ cPanel hosting account with PHP 8.1+ support ✓ MySQL database access ✓ SSH access (optional but recommended) ✓ Domain/subdomain configured 📦 STEP 1: PREPARE FILES FOR UPLOAD ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1. Compress the backend folder: - ZIP the entire 'backend' folder - OR use: zip -r backend.zip backend/ (excluding node_modules if any) 2. Files to include: ✓ All Laravel files ✓ .htaccess files (root and public/) ✓ vendor/ folder (with all dependencies) ✓ database/ folder 🗄️ STEP 2: CREATE MySQL DATABASE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1. Login to cPanel 2. Go to "MySQL Databases" 3. Create new database: Database Name: waste_management 4. Create database user: Username: waste_user Password: [Strong password - save it!] 5. Add user to database: - Select the user and database - Grant ALL PRIVILEGES 📤 STEP 3: UPLOAD FILES ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Method A - File Manager (Recommended for beginners): 1. Login to cPanel 2. Open "File Manager" 3. Navigate to public_html (or your domain folder) 4. Upload backend.zip 5. Right-click → Extract 6. Move all files from 'backend' folder to root Method B - FTP: 1. Use FileZilla or any FTP client 2. Connect to your hosting 3. Upload all files to public_html/ ⚙️ STEP 4: CONFIGURE ENVIRONMENT ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1. Locate the .env file in File Manager 2. Update these settings: APP_ENV=production APP_DEBUG=false APP_URL=https://yourdomain.com DB_CONNECTION=mysql DB_HOST=localhost DB_PORT=3306 DB_DATABASE=your_cpanel_username_waste_management DB_USERNAME=your_cpanel_username_waste_user DB_PASSWORD=your_database_password MAIL_MAILER=smtp MAIL_HOST=smtp.hostinger.com MAIL_PORT=465 MAIL_USERNAME=contact@getmyxam.com MAIL_PASSWORD=Demo4512@ MAIL_ENCRYPTION=ssl MAIL_FROM_ADDRESS="contact@getmyxam.com" MAIL_FROM_NAME="Waste Management" 3. Save the file 🗃️ STEP 5: IMPORT DATABASE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Method A - Using Terminal (if SSH available): cd public_html php artisan migrate --force php artisan db:seed --force Method B - Using phpMyAdmin: 1. Go to cPanel → phpMyAdmin 2. Select your database 3. Click "Import" 4. Upload database/database.sqlite file or create tables manually 🔐 STEP 6: SET PERMISSIONS ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Using File Manager, set these permissions: storage/ → 755 storage/framework/ → 755 storage/framework/cache/ → 755 storage/framework/sessions/ → 755 storage/framework/views/ → 755 storage/logs/ → 755 bootstrap/cache/ → 755 All files in these folders → 644 🔑 STEP 7: GENERATE APP KEY (if needed) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ If SSH available: php artisan key:generate If no SSH: Your .env already has: APP_KEY=base64:fkXWNmUWq8aGF5TBLqJ9uXZYVwI0qSPkVhDGJH4ZZBI= 🌐 STEP 8: UPDATE DOMAIN DNS ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1. In cPanel → Domains 2. Point your domain to the 'public' directory: - Document Root: /public_html/public OR - Create subdomain: api.yourdomain.com → /public_html/public 🧪 STEP 9: TEST YOUR API ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Visit: https://yourdomain.com/api/test Expected Response: { "success": true, "message": "API is working!", "version": "1.0.0" } 🔄 STEP 10: UPDATE FLUTTER APP ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Update lib/api_constants.dart: final String url = "https://yourdomain.com"; final String baseUrl = "https://yourdomain.com/api"; ✅ VERIFICATION CHECKLIST ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ □ Database created and user added □ All files uploaded □ .env configured with production settings □ Database tables created/imported □ Folder permissions set correctly □ Domain pointing to /public directory □ Test API endpoint working □ HTTPS/SSL certificate active □ Flutter app updated with production URL 🔧 TROUBLESHOOTING ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Problem: 500 Internal Server Error Solution: - Check storage/ permissions (755) - Enable debug: APP_DEBUG=true in .env - Check storage/logs/laravel.log Problem: Database connection error Solution: - Verify DB credentials in .env - Use full database name: cpanelusername_dbname - Check DB_HOST (usually 'localhost') Problem: Routes not working Solution: - Check .htaccess files are uploaded - Verify mod_rewrite is enabled - Check document root points to /public Problem: CORS errors Solution: - Update config/cors.php - Add your Flutter app domain to allowed origins 📞 SUPPORT ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ For deployment issues: - Check hosting provider documentation - Enable debug mode temporarily - Review Laravel logs in storage/logs/ ═══════════════════════════════════════════════════════════════════════ Deployment Guide - Waste Management Backend v1.0 ═══════════════════════════════════════════════════════════════════════