このチュートリアルでは、AlmaLinux 8にRustをインストールする方法を紹介します。知らなかった人のために、Rustはしばしばrust-langと呼ばれます。これは汎用です。 、マルチパラダイム、モダン、クロスプラットフォーム、およびオープンソースのシステムプログラミング言語。MozillaResearchが後援しています。Rustプログラミング言語には、デバイスドライバー、オペレーティングシステムの低レベルのコーディングなど、他にもさまざまな優れた機能があり、単純化されているため、使いやすく効率的です。
この記事は、少なくともLinuxの基本的な知識があり、シェルの使用方法を知っていること、そして最も重要なこととして、サイトを独自のVPSでホストしていることを前提としています。インストールは非常に簡単で、ルートアカウントで実行されていますが、そうでない場合は、'sudo
を追加する必要があります。 ルート権限を取得するコマンドに‘。 AlmaLinux8にRustプログラミング言語を段階的にインストールする方法を説明します。CentOSとRockyLinuxでも同じ手順に従うことができます。
前提条件
- 次のオペレーティングシステムのいずれかを実行しているサーバー:AlmaLinux 8、CentOS、およびRockyLinux8。
- 潜在的な問題を防ぐために、OSの新規インストールを使用することをお勧めします
non-root sudo user
またはroot user
へのアクセス 。non-root sudo user
として行動することをお勧めします ただし、ルートとして機能するときに注意しないと、システムに害を及ぼす可能性があるためです。
AlmaLinux8にRustをインストールする
ステップ1.まず、システムが最新であることを確認することから始めましょう。
sudo dnf update sudo dnf install epel-release sudo dnf install cmake gcc make
ステップ2.AlmaLinux8にRustをインストールします。
次に、以下のコマンドを使用してRustをダウンロードしてインストールします。
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
インストーラーがダウンロードされると、インストーラーが実行され、最初にインストールを続行するか、カスタマイズするか、キャンセルするかを尋ねられます。
info: downloading installer Welcome to Rust! This will download and install the official compiler for the Rust programming language, and its package manager, Cargo. It will add the cargo, rustc, rustup and other commands to Cargo's bin directory, located at: /home/idroot/.cargo/bin This can be modified with the CARGO_HOME environment variable. Rustup metadata and toolchains will be installed into the Rustup home directory, located at: /home/idroot/.rustup This can be modified with the RUSTUP_HOME environment variable. This path will then be added to your PATH environment variable by modifying the profile file located at: /home/idroot/.profile You can uninstall at any time with rustup self uninstall and these changes will be reverted. Current installation options: default host triple: x86_64-unknown-linux-gnu default toolchain: stable profile: default modify PATH variable: yes 1) Proceed with installation (default) 2) Customize installation 3) Cancel installation >1
インストーラーが終了すると、追加情報がユーザーに提供されます:
Rust is installed now. Great! To get started you need Cargo's bin directory ($HOME/.cargo/bin) in your PATH environment variable. Next time you log in this will be done automatically. To configure your current shell run source $HOME/.cargo/envを実行します。
最後に、次のコマンドを実行して現在のシェルを構成します。
source ~/.profile source ~/.cargo/env
以下のコマンドを実行して、システムにインストールされているRustのバージョンを確認します。
rustc -V
ステップ3.Rustサンプルプロジェクトを作成します。
「Hello、World!」を使用してRustをテストしてみましょう。アプリケーション。まず、次のコマンドを使用して、テストを格納するための新しいディレクトリを作成します。
mkdir ~/rust-projects cd rust-projects nano helloworld.rs
次の行を追加します:
fn main() { println!("Hello World, this is a test provided by idroot.us"); }
次に、次のコマンドを実行して、helloworld
という実行可能ファイルを作成します。 現在のディレクトリ:
rustc helloworld.rs
次に、実行コマンドを使用してプログラムを実行します:
./helloworld
おめでとうございます!Rustが正常にインストールされました。AlmaLinux8システムにRustプログラミング言語をインストールするためにこのチュートリアルを使用していただきありがとうございます。追加のヘルプや役立つ情報については、Rustの公式Webサイトを確認することをお勧めします。