Panduan Instalasi GOlang / Deploy Projek Golang di Cyberpanel

Panduan Step by Step untuk Instalasi GOlang / Deploy Projek Golang di Cyberpanel

Prasyarat:

Bisa pakai root atau user akses ssh, pastikan Anda telah menginstal:

  • Git
  • Wget

Daftar Isi

A. Langkah-langkah Instalasi Go

  1. Buat Website, dan aktifkan ssh akses
  2. Akses ssh / terminal yang telah dibuat, bisa pakai putty atau termius
  3. Download Go
    wget https://golang.org/dl/go1.23.2.linux-amd64.tar.gz

    Buat direktori untuk simpan go

    mkdir go
  4. Ekstrak Go ke Direktori yang telah dibuat
    tar -C /home/namadomain.com/go -xzf go1.23.2.linux-amd64.tar.gz
  5. Konfigurasi PATH
    Jalankan perintah : echo "export PATH=$PATH:/home/namadomain.com/go/go/bin" >> ~/.profile
  6. Muat Ulang Profil
    source ~/.profile
  7. Verifikasi Instalasi Go
    go version

B. Setup Projek Golang

  1. Bisa clone via github atau uploud file projek via filemanager cyberpanel ( direktori bebas asalkan didalam public_html)
  2. Instal Depedensi
    go mod tidy
  3. Jalankan Aplikasi di Latar Belakang ( agar aplikasi go nya selalu aktif meskipun terminal di close )
    cd /public_html

    public_html  sesuikan dengan lokasi tempat projek
    Kemudian jalankan

    nohup go run main.go > output.log 2>&1 &
  4. Memeriksa Proses yang Berjalan
    lsof -i :3000

    port 3000 ganti sesuai projek anda

  5. Menghentikan Aplikasi / proses berjalan
    kill -9 <PID>

    PID ganti dengan id PID yang ingin di hentikan

C. Konfigurasi Projek GOlang agar bisa diakses public via domain / IP

  1. Open port OpenLitespeed Pada dashboard cyberpanel, buka menu security > Firewall > Jika status off silahkan di on dulu.
    Tambahkan port 7080 > protocol : tcp >> IP address : 0.0.0.0/0 >> Save
  2. Masuk ek Openlitespeed IPServer:7080 atau namadomain:7080
  3. Setting Proxy
    1. Setting External App
      • Pilih menu `virtual hosts`> Pilih Domain > External App
      • Tambahkan baru dengan cara klik icon +
      • type : Webserver >> next
      • Nama isi misalkan `apigolang`
      • Address isi sesuai port, contoh localhost:3000   (portnya sesuaikan)
      • Max Connection >> 100
      • Connection Keep-Alive Timeout >> 60
      • Initial Request Timeout (secs) >> 60
      • Retry Timeout (secs) >> 0
      • Response Buffering pilih `No`
      • Simpan (Klik pada icon save)
    2. Membuat Proxy
      • Masuk ke menu `Context`
      • Add dengan klik tombol + dan pilih proxy >> Next
      • Kolom uri isi `/`
      • Webserver pilih yang disetting pada tahap `a` diatas
      • Simpan (Klik pada icon save)
    3. Restart OpenLiteSpeed (klik icon restart warna hijau)
Done..
Semoga bermanfaat !!
Cari developer ? atau mau buat aplikasi dan website bisa hubungi admin wa.me/6288805640427 atau https://tech.mudahdeal.com

 

Leave a Comment