Laravel Deployment on cPanel – Step-by-Step GuidePre-Deployment ChecklistBefore you start, make sure you have: - ✅ Production assets built (`public/build/`) - ✅ Security headers middleware in place - ✅ Laravel config optimized (`config:cache`) - ✅ Session & cache drivers set to `file` - ✅ Correct timezone (`Asia/Kathmandu`) - ✅ `.env.production` file template ready ---Step 1: Package Your Laravel AppUpload These:```app/bootstrap/config/database/public/resources/routes/storage/vendor/artisancomposer.jsoncomposer.lock```### Exclude These:```.git/node_modules/tests/.env.env.example*.mdstorage/logs/*storage/framework/cache/*storage/framework/sessions/*storage/framework/views/*```---Step 2: Upload to cPanel1. Log in → **File Manager** → `public_html/` 2. Upload your Laravel package (ZIP is easiest) 3. Extract the files ⚠️ **Document Root Setup:** - Go to **Domains → Manage → example.com** - Set **Document Root** → `public_html/public/` ---Step 3: Configure Environment1. Create `.env` in `public_html/` 2. Paste and update credentials (DB, mail, APP_KEY). Generate Key:- If terminal available: `php artisan key:generate` - If not: run locally, copy to server. Example `.env` snippet: ```APP_NAME="My Laravel App"APP_ENV=productionAPP_KEY=base64:YOUR_GENERATED_KEY_HEREAPP_DEBUG=falseAPP_URL=https://example.comAPP_TIMEZONE=Asia/KathmanduDB_CONNECTION=mysqlDB_HOST=localhostDB_PORT=3306DB_DATABASE=example_dbDB_USERNAME=example_userDB_PASSWORD=example_passMAIL_MAILER=smtpMAIL_HOST=mail.example.comMAIL_PORT=587MAIL_USERNAME=your_email@example.comMAIL_PASSWORD=your_email_passwordMAIL_ENCRYPTION=tlsMAIL_FROM_ADDRESS=your_email@example.comMAIL_FROM_NAME="My Laravel App"```---Step 4: Database Setup1. Create database & user in **MySQL Databases** 2. Assign user → database with **ALL PRIVILEGES** 3. Update `.env` with DB credentials Migrations:- With terminal: `php artisan migrate --force` - Without: use **phpMyAdmin → Import** ---Step 5: Permissions- `storage/` → 755 - `bootstrap/cache/` → 755 - `.env` → 644 ---Step 6: Final OptimizationIf terminal available: ```php artisan config:clearphp artisan cache:clearphp artisan route:cachephp artisan view:cache```**Storage Link (CRITICAL for images):** ```php artisan storage:link```👉 Without terminal: manually copy `storage/app/public/` → `public/storage/`. ---Step 7: Test & Verify- **Homepage:** `https://example.com` - **Admin Panel:** `https://example.com/admin` - **Forms, Blog, Contact pages** Check: **Error Logs** in cPanel → fix any PHP/database issues. ---Security & Performance- ✅ HTTPS enforced (SSL) - ✅ Security headers (X-Frame, CSP, etc.) - ✅ CSRF protection - ✅ Minified assets - ✅ Config & route caching ---Troubleshooting**White Page/500 Error** → Check `.env`, file permissions, root = `public/`. **DB Errors** → Wrong credentials or privileges. **Images Missing** → Run `storage:link` or copy manually. **Assets Not Loading** → Ensure `public/build/` exists. ---🎉 Done!Your Laravel app is live, secure, and production-ready — all from cPanel, no SSH required! 🚀