Dalam panduan ini, kita akan menginstal Erlang/OTP di Rocky Linux/Alma Linux/CentOS 8.
Konten Terkait
- Cara menginstal Rabbitmq di Rocky Linux/Alma Linux/Centos 8
- Cara menginstal RabbitMQ di Fedora 35
- Cara menginstal Erlang di Fedora 35
Prasyarat
Anda perlu mengikuti yang berikut ini
- Server Rocky Linux/Alma Linux 8 yang diperbarui
- Akses root atau pengguna dengan akses root
- Akses internet dari server
Daftar Isi
- Memperbarui sistem
- Menginstal Erlang
- Membuat program Hello world
1. Memperbarui sistem
Mari kita pastikan bahwa paket server kita up to date menggunakan perintah ini:
sudo dnf -y update
Mari kita juga menginstal beberapa paket umum
sudo dnf install vim -y
2. Memasang Erlang
Paket Erlang didistribusikan melalui repositori Yum di PackageCloud. Instal repositori PackageCloud Yum menggunakan perintah ini:
curl -s https://packagecloud.io/install/repositories/rabbitmq/erlang/script.rpm.sh | sudo bash
Ini adalah output di server saya
$ curl -s https://packagecloud.io/install/repositories/rabbitmq/erlang/script.rpm.sh | sudo bash
Detected operating system as rocky/8.
Checking for curl...
Detected curl...
Downloading repository file: https://packagecloud.io/install/repositories/rabbitmq/erlang/config_file.repo?os=rocky&dist=8&source=script
done.
Installing yum-utils...
Rocky Linux 8 - AppStream 15 kB/s | 4.8 kB 00:00
Rocky Linux 8 - BaseOS 6.5 kB/s | 4.3 kB 00:00
Rocky Linux 8 - Extras 27 kB/s | 3.5 kB 00:00
rabbitmq_erlang-source 1.3 kB/s | 819 B 00:00
rabbitmq_erlang-source 21 kB/s | 3.8 kB 00:00
Importing GPG key 0xDF309A0B:
Userid : "https://packagecloud.io/rabbitmq/erlang (https://packagecloud.io/docs#gpg_signing) <[email protected]>"
Fingerprint: 2EBD E413 D3CE 5D35 BCD1 5B7C 71C6 3471 DF30 9A0B
From : https://packagecloud.io/rabbitmq/erlang/gpgkey
rabbitmq_erlang-source 357 B/s | 296 B 00:00
Package yum-utils-4.0.18-4.el8.noarch is already installed.
Dependencies resolved.
Nothing to do.
Complete!
Generating yum cache for rabbitmq_erlang...
Importing GPG key 0xDF309A0B:
Userid : "https://packagecloud.io/rabbitmq/erlang (https://packagecloud.io/docs#gpg_signing) <[email protected]>"
Fingerprint: 2EBD E413 D3CE 5D35 BCD1 5B7C 71C6 3471 DF30 9A0B
From : https://packagecloud.io/rabbitmq/erlang/gpgkey
Generating yum cache for rabbitmq_erlang-source...
The repository is setup! You can now install packages.
Sekarang kita dapat menginstal erlang dari repo yang ditambahkan:
$ sudo dnf install erlang
Last metadata expiration check: 0:00:27 ago on Fri 12 Nov 2021 07:30:53 AM EAT.
Dependencies resolved.
===============================================================================================================================================================
Package Architecture Version Repository Size
===============================================================================================================================================================
Installing:
erlang x86_64 24.1-1.el8 rabbitmq_erlang 20 M
Transaction Summary
===============================================================================================================================================================
Install 1 Package
Total download size: 20 M
Installed size: 36 M
Is this ok [y/N]: y
Downloading Packages:
erlang-24.1-1.el8.x86_64.rpm 42 MB/s | 20 MB 00:00
---------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 41 MB/s | 20 MB 00:00
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Installing : erlang-24.1-1.el8.x86_64 1/1
Running scriptlet: erlang-24.1-1.el8.x86_64 1/1
Verifying : erlang-24.1-1.el8.x86_64 1/1
Installed:
erlang-24.1-1.el8.x86_64
Complete!
3. Membuat program Hello world
Buat hello.erl
berkas
vim hello.erl
Tambahkan ini ke file
% This is a test Hello World Erlang Code
-module(hello).
-import(io,[fwrite/1]).
-export([helloworld/0]).
helloworld() ->
fwrite("Hello from Citizix, Erlang World!\n").
Kompilasi dari shell Erlang. Jangan lupa tanda titik (“titik”) di akhir setiap perintah:
$ erl
Erlang/OTP 24 [erts-12.1] [source] [64-bit] [smp:2:2] [ds:2:2:10] [async-threads:1] [jit]
Eshell V12.1 (abort with ^G)
1> c(hello).
{ok,hello}
2> hello:helloworld().
Hello from Citizix, Erlang World!
ok
3>
Anda telah berhasil menginstal Erlang di sistem Anda.
Kesimpulan
Terima kasih telah menggunakan tutorial ini untuk menginstal bahasa pemrograman Erlang pada sistem Rocky Linux/Alma Linux 8 Anda. Untuk bantuan tambahan atau informasi yang berguna, kami menyarankan Anda untuk memeriksa situs resmi Erlang.