🚀 Panduan Lengkap Hostiqo

Panel Pengurusan Server & Auto-Deploy

Kursus: Deploy Aplikasi Web ke Cloud Server

Pengajar: Ahmad Saiful Bahri

Kemaskini: Januari 2026

📋 Objektif Pembelajaran

Selepas mengikuti kursus ini, anda akan dapat:

  • ✅ Menyediakan cloud server dengan panel Hostiqo
  • ✅ Menyediakan aplikasi React/Static untuk production
  • ✅ Melakukan deployment aplikasi ke server dengan auto-deploy
  • ✅ Mengkonfigurasi domain dan SSL certificate (HTTPS)
  • ✅ Menyelesaikan masalah teknikal yang biasa berlaku

📦 Keperluan Sebelum Memulakan

Akaun yang Diperlukan

Akaun Kegunaan Pautan
Cloud Provider Server hosting Lihat pilihan di bawah
GitHub Repository kod github.com
Domain Alamat website Cloudflare / Namecheap / etc

Pilihan Cloud Provider

Pilihan 1 - DigitalOcean (Antarabangsa)

  • Pautan: https://m.do.co/c/9709748ce8a4
  • Lokasi server: Singapore
  • Harga bermula: ~$6/bulan (USD)
  • Kelebihan: Interface mesra pengguna, dokumentasi lengkap

Pilihan 2 - GB Network Hosting (Malaysia)

Spesifikasi Server Minimum

Item Minimum Disyorkan
RAM 1 GB 2 GB
CPU 1 vCPU 2 vCPU
Storage 25 GB SSD 50 GB SSD
OS Ubuntu 24.04 LTS Ubuntu 24.04 LTS

BAHAGIAN A Penyediaan Server

Langkah 1: Cipta Virtual Server

Untuk DigitalOcean:

  1. Login ke DigitalOcean
  2. Klik CreateDroplets
  3. Pilih konfigurasi berikut:
    • Region: Singapore
    • Image: Ubuntu 24.04 (LTS) x64
    • Size: Basic → Regular → $6/month
    • Authentication: Password
  4. Hostname: class-server (atau nama pilihan anda)
  5. Klik Create Droplet
  6. Catatkan IP Address (contoh: 146.190.99.138)

Untuk GB Network:

  1. Login ke GB Network
  2. Pilih Cloud VPS → Pakej pilihan anda
  3. Pilih konfigurasi:
    • OS: Ubuntu 24.04 LTS
    • Location: Malaysia
  4. Lengkapkan pembayaran
  5. Catatkan IP Address dari email confirmation

Langkah 2: Konfigurasi DNS

Sebelum memasang Hostiqo, domain perlu diarahkan ke IP server.

Di Cloudflare / DNS Provider:

Pilihan 1 - Wildcard (Disyorkan):

Type: A
Name: *
Content: [IP_SERVER_ANDA]
TTL: Auto

Dengan wildcard, semua subdomain akan berfungsi secara automatik.

Pilihan 2 - Subdomain Tertentu:

Type: A
Name: panel
Content: [IP_SERVER_ANDA]
TTL: Auto
⏰ Nota: Sila tunggu 2-5 minit untuk DNS propagation sebelum meneruskan.

Langkah 3: Login ke Server

Buka terminal (Mac/Linux/WSL) dan jalankan arahan SSH:

ssh root@[IP_SERVER_ANDA]

Contoh:

ssh root@146.190.99.138

Jika mendapat soalan fingerprint, taipkan yes:

Are you sure you want to continue connecting? yes

Masukkan password dan anda akan melihat prompt:

root@class-server:~#

Langkah 4: Pre-Update System (WAJIB)

⚠️ PENTING: Langkah ini WAJIB dilakukan sebelum memasang Hostiqo!
apt-get update -y && apt-get upgrade -y

Mengapa Langkah Ini Wajib?

Installer Hostiqo menyembunyikan semua output untuk paparan yang lebih kemas. Namun, jika terdapat prompt interaktif (contoh: "keep existing config?"), anda tidak akan dapat melihatnya. Ini akan menyebabkan installer tersekat tanpa sebarang mesej error.

Jika Mendapat Prompt Konfigurasi:

Configuration file '/etc/xxxxx'
 ==> Modified (by you or by a script) since installation.
    What would you like to do about it?

Jawapan: Tekan Enter untuk mengekalkan konfigurasi default.

Jika Mendapat Error "Lock":

E: Could not get lock /var/lib/dpkg/lock-frontend

Penyelesaian: Tunggu 2-3 minit kerana terdapat proses apt lain yang sedang berjalan, kemudian cuba semula.

Langkah 5: Pasang Hostiqo

Jalankan arahan berikut untuk memulakan pemasangan:

curl -fsSL https://raw.githubusercontent.com/hymns/hostiqo/master/scripts/install.sh | bash

Panduan Menjawab Soalan Installer:

Soalan Jawapan
Continue with installation? (y/n) Taip y → Enter
Installation path ⚠️ Tekan Enter sahaja! Jangan taip apa-apa!
Setup database automatically? y
Database name Tekan Enter (gunakan default)
Database user Tekan Enter (gunakan default)
Database password Taip password yang kukuh
Create admin user? y
Admin name Nama anda
Admin email Email anda (untuk login panel)
Admin password Password untuk login panel
Domain name panel.yourdomain.com
Include www subdomain? n
Setup SSL certificate? y
Email for SSL Email anda
⏱️ Masa: Proses pemasangan mengambil masa 15-25 minit.

Output Jangkaan Selepas Selesai:

==========================================
Installation Complete! 🎉
==========================================

✓ Hostiqo has been installed successfully!
→ Access your panel at: https://panel.yourdomain.com

Langkah 6: Akses Panel Hostiqo

  1. Buka web browser
  2. Layari https://panel.yourdomain.com
  3. Login menggunakan email dan password admin yang telah dicipta
🎉 Tahniah! Panel Hostiqo anda sudah sedia untuk digunakan!

BAHAGIAN B Menyediakan Aplikasi dari Google AI Studio

Langkah 1: Generate Kod yang Production-Ready

Apabila meminta Google AI Studio menjana aplikasi React, sertakan arahan khusus supaya kod yang dihasilkan sedia untuk deployment.

Contoh Prompt untuk AI Studio:

Create a [DESCRIPTION OF YOUR APP] using React with Vite.

IMPORTANT - Please ensure the code is production-ready:
1. Use Vite as the build tool with proper vite.config.js
2. Include a complete package.json with these scripts:
   - "dev": "vite"
   - "build": "vite build"
   - "preview": "vite preview"
3. Ensure all assets (images, fonts) use relative paths
4. Do not use environment variables that only work in development
5. Make sure the app works when served as static files from /dist folder
6. Include proper index.html in the root folder
7. All API calls should use full URLs, not relative paths

Contoh Prompt Lengkap:

Create a weather forecast app using React with Vite that shows current weather and 5-day forecast.

IMPORTANT - Please ensure the code is production-ready:
1. Use Vite as the build tool with proper vite.config.js
2. Include a complete package.json with these scripts:
   - "dev": "vite"
   - "build": "vite build"  
   - "preview": "vite preview"
3. Ensure all assets use relative paths
4. The app must work when served as static files from /dist folder
5. Use Tailwind CSS for styling
6. Include proper error handling for API calls

Struktur Fail yang Diperlukan:

Pastikan projek anda mempunyai struktur berikut:

project/
├── index.html          ← Entry point
├── package.json        ← Dependencies & scripts
├── vite.config.js      ← Vite configuration
├── src/
│   ├── main.jsx        ← React entry
│   ├── App.jsx         ← Main component
│   └── components/     ← Other components
└── public/             ← Static assets

Semak package.json:

Pastikan package.json mempunyai scripts berikut:

{
  "scripts": {
    "dev": "vite",
    "build": "vite build",
    "preview": "vite preview"
  }
}

Langkah 2: Muat Turun dan Sediakan Projek

  1. Di Google AI Studio, klik Download atau Export untuk memuat turun projek
  2. Extract fail zip ke folder pilihan anda
  3. Buka terminal di dalam folder tersebut

Test Build Secara Lokal (Pilihan):

npm install
npm run build
npm run preview

Jika tiada error, projek anda sedia untuk deployment.

Langkah 3: Push ke GitHub

Jika Belum Ada Repository:

cd /path/to/your/project

git init
git add .
git commit -m "Initial commit"

Cipta Repository di GitHub:

  1. Login ke GitHub
  2. Klik +New repository
  3. Masukkan nama repository
  4. Pilih Private (disyorkan)
  5. Klik Create repository

Push Kod ke GitHub:

git remote add origin git@github.com:USERNAME/REPO.git
git branch -M main
git push -u origin main

BAHAGIAN C Deploy Aplikasi Static/React

Langkah 1: Cipta Website di Hostiqo (TANPA SSL Dahulu)

⚠️ PENTING: Gunakan PHP Website untuk aplikasi static/React, bukan Node.js Website.
⚠️ PENTING: JANGAN enable SSL pada langkah ini! SSL hanya boleh diaktifkan selepas deployment pertama berjaya. Ini kerana Hostiqo perlu folder/fail website wujud terlebih dahulu untuk generate SSL certificate.
  1. Login ke panel Hostiqo
  2. Klik WebsitesPHP ProjectsAdd PHP Website

Konfigurasi Website:

Field Value
Name nama-aplikasi-anda
Domain app.yourdomain.com
Root Path /var/www/nama_aplikasi
Working Directory /dist
PHP Version 8.3 (sebarang versi)
Enable SSL No (akan diaktifkan kemudian)

3. Klik Save

💡 Nota: Working Directory ditetapkan kepada /dist kerana React/Vite menghasilkan fail build di dalam folder tersebut.

Langkah 2: Cipta Webhook untuk Auto-Deploy

1. Klik WebhooksCreate Webhook

Basic Information:

Field Value
Name Deploy [Nama App]
Domain (pilih website yang dicipta)
Status Active

Repository Configuration:

Field Value
Git Provider GitHub
Repository URL git@github.com:USERNAME/REPO.git
Branch main
Local Path /var/www/nama_aplikasi
Deploy User www-data

SSH Key:

  • ✅ Tandakan Auto-generate SSH Key Pair

2. Klik Save

Langkah 3: Konfigurasi Post-Deploy Script

  1. Buka semula webhook yang dicipta
  2. Klik Edit
  3. Scroll ke bahagian Post-Deploy Script
  4. Masukkan script berikut:
#!/bin/bash

# Install dependencies
npm install

# Build aplikasi untuk production
npm run build

5. Klik Save

Langkah 4: Setup GitHub Deploy Key

  1. Di Hostiqo, buka webhook tadi
  2. Salin SSH Public Key
  3. Di GitHub repository → SettingsDeploy keysAdd deploy key
Field Value
Title Hostiqo Deploy Key
Key (paste SSH key yang disalin)
Allow write access ❌ No

4. Klik Add key

Langkah 5: Setup GitHub Webhook

1. Di GitHub repository → SettingsWebhooksAdd webhook

Field Value
Payload URL (salin dari Hostiqo)
Content type application/json
Secret (salin dari Hostiqo)
Events Just the push event
Active ✅ Yes

2. Klik Add webhook

Langkah 6: Lakukan Deployment Pertama

Pilihan 1 - Manual Deploy:

Di panel Hostiqo, klik butang Deploy Now

Pilihan 2 - Auto Deploy:

Push sebarang perubahan ke GitHub:

git add .
git commit -m "Update aplikasi"
git push

Proses yang Berlaku:

  1. GitHub menerima push → trigger webhook
  2. Hostiqo menerima signal → queue deployment
  3. Server clone/pull kod terkini
  4. Jalankan npm install → install dependencies
  5. Jalankan npm run build → generate folder /dist
  6. Nginx serve fail static dari /dist

Langkah 7: Aktifkan SSL Certificate

⚠️ Nota: Langkah ini HANYA boleh dilakukan SELEPAS deployment pertama berjaya!
  1. Di panel Hostiqo, pergi ke Websites
  2. Klik pada website yang telah di-deploy
  3. Klik Edit atau ikon settings
  4. Enable Let's Encrypt SSL
  5. Klik Save
  6. Tunggu sehingga SSL status bertukar kepada Active
💡 Mengapa perlu tunggu deployment dulu? Hostiqo memerlukan folder website wujud terlebih dahulu untuk memohon SSL certificate. Jika folder belum wujud, proses SSL akan gagal.

Langkah 8: Semak Status Deployment

  1. Di panel Hostiqo, klik Deployments
  2. Lihat status deployment:
    • Success ✅ - Deployment berjaya
    • Failed ❌ - Ada masalah (klik untuk lihat log)
    • Pending 🟡 - Sedang dalam proses
  3. Layari domain anda untuk melihat aplikasi: https://app.yourdomain.com

BAHAGIAN D Penyelesaian Masalah (Troubleshooting)

Masalah 1: Installer Tersekat pada "Updating system packages..."

Punca: Terdapat prompt tersembunyi yang menunggu input pengguna.

Penyelesaian:

  1. Rebuild/reset server
  2. Jalankan pre-update secara manual SEBELUM installer:
apt-get update -y && apt-get upgrade -y
  1. Jawab semua prompt yang muncul
  2. Kemudian jalankan installer Hostiqo

Masalah 2: Nginx Failed - SSL Directive Duplicate

Error:

"ssl_session_timeout" directive is duplicate in /etc/letsencrypt/options-ssl-nginx.conf

Punca: Conflict antara SSL config Hostiqo dan Let's Encrypt.

Penyelesaian:

# Comment semua ssl directives dalam fail Let's Encrypt
sed -i 's/^ssl_/#ssl_/' /etc/letsencrypt/options-ssl-nginx.conf

# Test konfigurasi Nginx
nginx -t

# Jika OK, reload Nginx
systemctl reload nginx

Kemudian klik Redeploy di panel Hostiqo.

Masalah 3: SSH Fingerprint Error

Error:

WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!

Punca: Server telah di-rebuild dan fingerprint berubah.

Penyelesaian (jalankan di terminal lokal):

ssh-keygen -R [IP_SERVER_ANDA]

Kemudian SSH semula ke server.

Masalah 4: apt-get Lock Error

Error:

E: Could not get lock /var/lib/dpkg/lock-frontend

Punca: Proses apt lain sedang berjalan.

Penyelesaian: Tunggu 2-3 minit, kemudian cuba semula. Atau semak proses yang sedang berjalan:

ps aux | grep apt

Masalah 5: Deployment Tersekat pada Status "Pending"

Penyelesaian:

# Semak status queue worker
sudo supervisorctl status

# Restart queue worker
sudo supervisorctl restart hostiqo-queue:*

# Semak log untuk error
tail -f /var/www/hostiqo/storage/logs/laravel.log

Masalah 6: Permission Denied Semasa Deployment

Penyelesaian:

sudo chown -R www-data:www-data /var/www/nama_aplikasi
sudo chmod -R 755 /var/www/nama_aplikasi

Masalah 7: 502 Bad Gateway

Penyelesaian:

# Semak status PHP-FPM
sudo systemctl status php8.3-fpm

# Restart PHP-FPM
sudo systemctl restart php8.3-fpm

# Semak log
tail -f /var/log/php8.3-fpm.log

Masalah 8: React App Paparan Blank/Kosong

Punca Biasa:

  1. Aplikasi belum di-build
  2. Working directory tidak betul
  3. Kod tidak production-ready

Penyelesaian:

  1. Pastikan post-deploy script mempunyai:
    npm install
    npm run build
  2. Pastikan Working Directory di website settings adalah /dist
  3. Semak sama ada folder /dist wujud di server:
    ls -la /var/www/nama_aplikasi/dist/
  4. Jika folder kosong atau tiada, build mungkin gagal. Semak log deployment untuk error.
  5. Pastikan kod dari AI Studio adalah production-ready (rujuk Bahagian B, Langkah 1)

Masalah 9: SSL Certificate Failed

Punca Biasa:

  1. Cuba enable SSL sebelum deployment pertama
  2. Folder website belum wujud
  3. DNS belum point ke server

Penyelesaian:

  1. Pastikan deployment pertama sudah berjaya SEBELUM enable SSL:
    • Cipta website TANPA SSL
    • Cipta webhook dan deploy
    • Pastikan folder /var/www/nama_aplikasi/dist wujud
    • Kemudian baru enable SSL
  2. Semak DNS sudah point ke server:
    dig +short yourdomain.com
  3. Request SSL secara manual (jika perlu):
    sudo certbot --nginx -d yourdomain.com
  4. Semak konfigurasi Nginx:
    nginx -t

Masalah 10: npm run build Gagal

Punca Biasa: Kod dari AI Studio tidak lengkap atau ada error.

Penyelesaian:

  1. Test build di lokal terlebih dahulu:
    npm install
    npm run build
  2. Jika ada error, minta AI Studio generate semula dengan prompt yang lebih spesifik (rujuk Bahagian B, Langkah 1)
  3. Pastikan vite.config.js wujud dan betul

BAHAGIAN E Rujukan Pantas

Arahan Server

# Nginx
sudo nginx -t                    # Test konfigurasi
sudo systemctl reload nginx      # Reload
sudo systemctl restart nginx     # Restart

# PHP-FPM
sudo systemctl restart php8.3-fpm

# MySQL
sudo systemctl restart mysql

# Redis
sudo systemctl restart redis-server

# Supervisor (queue workers)
sudo supervisorctl status
sudo supervisorctl restart all

Lokasi Fail Log

# Log Hostiqo
tail -f /var/www/hostiqo/storage/logs/laravel.log

# Log Nginx
tail -f /var/log/nginx/error.log
tail -f /var/log/nginx/access.log

# Log aplikasi anda
tail -f /var/www/nama_aplikasi/storage/logs/laravel.log

Lokasi Fail Penting

Path Keterangan
/var/www/hostiqo Pemasangan Hostiqo
/var/www/ Root folder untuk websites
/etc/nginx/sites-available/ Konfigurasi Nginx
/root/.mysql_root_password Password root MySQL

Update Hostiqo

cd /var/www/hostiqo
sudo php artisan hostiqo:update --sudoers

✅ Senarai Semak Deployment

Penyediaan Server

  • Server cloud telah dicipta
  • DNS telah dikonfigurasi
  • SSH berfungsi
  • Pre-update telah dilakukan
  • Hostiqo telah dipasang
  • Panel boleh diakses

Deploy Aplikasi

  • Kod production-ready (boleh build tanpa error)
  • Repository GitHub telah dicipta
  • Website dicipta di Hostiqo (TANPA SSL dahulu)
  • Webhook dicipta
  • Deploy key ditambah ke GitHub
  • GitHub webhook dikonfigurasi
  • Post-deploy script ditetapkan
  • Deployment pertama berjaya
  • SSL diaktifkan (SELEPAS deployment pertama)
  • SSL status Active
  • Website boleh diakses via HTTPS

💡 Tips Penting

  1. Sentiasa pre-update sistem sebelum memasang Hostiqo
  2. Jangan taip 'y' untuk installation path - tekan Enter sahaja!
  3. Gunakan PHP Website untuk aplikasi React/static, bukan Node.js Website
  4. Working Directory /dist untuk aplikasi React/Vite
  5. Test build di lokal sebelum push ke server
  6. Gunakan prompt yang betul di AI Studio untuk kod production-ready
  7. Semak log apabila berlaku error
  8. Enable SSL SELEPAS deployment pertama - jangan enable semasa create website!