MIF_E31232103/DEPLOYMENT.md

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:
    • ctype
    • curl
    • dom
    • fileinfo
    • filter
    • mbstring
    • openssl
    • pdo_mysql
    • tokenizer
    • xml
    • zip

Langkah Deployment

  1. Upload source code ke server.
  2. Install dependency production.
composer install --optimize-autoloader --no-dev
  1. Salin file environment.
cp .env.example .env
  1. Edit .env produksi.
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
  1. Generate application key jika belum ada.
php artisan key:generate
  1. Jalankan migration.
php artisan migrate --force
  1. Jika butuh data demo untuk presentasi, jalankan seeder.
php artisan db:seed --force
  1. Buat storage symlink.
php artisan storage:link
  1. 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 .env tidak bisa diakses publik
  • Pastikan public/index.php menjadi document root
  • Pastikan public/storage tersedia
  • Pastikan database backup dibuat sebelum deploy

Catatan Keamanan

  • APP_DEBUG=false di production
  • Gunakan password database yang kuat
  • Jangan upload .env ke 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