2.3 KiB
2.3 KiB
Deployment Guide
Panduan deployment Laravel untuk project WebRental.
Kebutuhan Server
- PHP 8.2 atau lebih baru
- Composer
- Web server: Nginx atau Apache
- MySQL / MariaDB
- Extension PHP umum:
ctypecurldomfileinfofiltermbstringopensslpdo_mysqltokenizerxmlzip
Langkah Deployment
- Upload source code ke server.
- Install dependency production.
composer install --optimize-autoloader --no-dev
- Salin file environment.
cp .env.example .env
- Edit
.envproduksi.
APP_NAME=WebRental
APP_ENV=production
APP_DEBUG=false
APP_URL=https://domain-anda.com
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=webrental
DB_USERNAME=webrental_user
DB_PASSWORD=rahasia
- Generate application key jika belum ada.
php artisan key:generate
- Jalankan migration.
php artisan migrate --force
- Jika butuh data demo untuk presentasi, jalankan seeder.
php artisan db:seed --force
- Buat storage symlink.
php artisan storage:link
- Optimalkan cache Laravel.
php artisan config:cache
php artisan route:cache
php artisan view:cache
Permission Folder
Pastikan folder ini writable oleh web server:
storage/bootstrap/cache/
Contoh di Linux:
chmod -R 775 storage bootstrap/cache
Setelah Deploy
- Pastikan
.envtidak bisa diakses publik - Pastikan
public/index.phpmenjadi document root - Pastikan
public/storagetersedia - Pastikan database backup dibuat sebelum deploy
Catatan Keamanan
APP_DEBUG=falsedi production- Gunakan password database yang kuat
- Jangan upload
.envke repository publik - Gunakan HTTPS
- Backup database secara rutin
- Jika seeder demo dipakai di staging, hindari di production final kecuali memang diperlukan
Command Operasional
php artisan migrate --force
php artisan db:seed --force
php artisan storage:link
php artisan optimize
Troubleshooting
- Jika view lama masih muncul, jalankan:
php artisan optimize:clear
- Jika route tidak terbaca, jalankan:
php artisan route:clear
- Jika cache konfigurasi bermasalah, jalankan:
php artisan config:clear
php artisan view:clear