AlmaLinux 9.0にRust 1.61をインストールする手順

環境
OSバージョンの確認
# cat /etc/redhat-release
AlmaLinux release 9.0 (Emerald Puma)

Rustのインストール手順
1.システムパッケージを更新します

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# sudo dnf upgrade --refresh
# sudo dnf upgrade --refresh
# sudo dnf upgrade --refresh

2.必要なパッケージをインストールします
EPELリポジトリをインストールします

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# sudo dnf install epel-release -y
# sudo dnf install epel-release -y
# sudo dnf install epel-release -y

CMake、GCC、Makeパッケージをインストールします

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# sudo dnf install cmake gcc make curl -y
# sudo dnf install cmake gcc make curl -y
# sudo dnf install cmake gcc make curl -y

3.Rustプログラム言語をインストールします

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
1) Proceed with installation (default)
2) Customize installation
3) Cancel installation
>1
Rust is installed now. Great!
To get started you may need to restart your current shell.
This would reload your PATH environment variable to include
Cargo's bin directory ($HOME/.cargo/bin).
To configure your current shell, run:
source $HOME/.cargo/env
# curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh 略 1) Proceed with installation (default) 2) Customize installation 3) Cancel installation >1 略 Rust is installed now. Great! To get started you may need to restart your current shell. This would reload your PATH environment variable to include Cargo's bin directory ($HOME/.cargo/bin). To configure your current shell, run: source $HOME/.cargo/env
# curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
略
1) Proceed with installation (default)
2) Customize installation
3) Cancel installation
>1
略
Rust is installed now. Great!

To get started you may need to restart your current shell.
This would reload your PATH environment variable to include
Cargo's bin directory ($HOME/.cargo/bin).

To configure your current shell, run:
source $HOME/.cargo/env

4.環境変数を反映します

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# source ~/.profile
# source ~/.cargo/env
# source ~/.profile # source ~/.cargo/env
# source ~/.profile
# source ~/.cargo/env

5.Rustバージョンを確認します。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# rustc -V
rustc 1.61.0 (fe5b13d68 2022-05-18)
# rustc -V rustc 1.61.0 (fe5b13d68 2022-05-18)
# rustc -V
rustc 1.61.0 (fe5b13d68 2022-05-18)

6.Rustプロジェクトを作成します
# mkdir -p /data/rust-projects
ディレクトリに移動します

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# cd /data/rust-projects
# nano helloworld.rs
# cd /data/rust-projects # nano helloworld.rs
# cd /data/rust-projects
# nano helloworld.rs

以下の内容を編集します

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
fn main() {
println!("Hello World, study skill become smart arkgame.com");
}
fn main() { println!("Hello World, study skill become smart arkgame.com"); }
fn main() {
    println!("Hello World, study skill become smart arkgame.com");
}

ファイルをコンパイルします
# rustc helloworld.rs

コンパイルしたファイルを実行します

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# ./helloworld
Hello World, study skill become smart arkgame.com
# ./helloworld Hello World, study skill become smart arkgame.com
# ./helloworld
Hello World, study skill become smart arkgame.com

 

AlmaLinux

Posted by arkgame