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
- Buat Website, dan aktifkan ssh akses
- Akses ssh / terminal yang telah dibuat, bisa pakai putty atau termius
- Download Go
wget https://golang.org/dl/go1.23.2.linux-amd64.tar.gz
Buat direktori untuk simpan go
mkdir go
- Ekstrak Go ke Direktori yang telah dibuat
tar -C /home/namadomain.com/go -xzf go1.23.2.linux-amd64.tar.gz
- Konfigurasi PATH
Jalankan perintah : echo "export PATH=$PATH:/home/namadomain.com/go/go/bin" >> ~/.profile
- Muat Ulang Profil
source ~/.profile
- Verifikasi Instalasi Go
go version
B. Setup Projek Golang
- Bisa clone via github atau uploud file projek via filemanager cyberpanel ( direktori bebas asalkan didalam public_html)
- Instal Depedensi
go mod tidy
- 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 jalankannohup go run main.go > output.log 2>&1 &
- Memeriksa Proses yang Berjalan
lsof -i :3000
port 3000 ganti sesuai projek anda
- 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
- 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 - Masuk ek Openlitespeed IPServer:7080 atau namadomain:7080
- Setting Proxy
-
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)
-
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)
-
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