Originally published on php2rust.dev — part of the PHP to Rust course. View this lesson on the original site.

The standard way to install Rust is rustup: a small installer that gives you the compiler (rustc), the package manager and build tool (Cargo), and the ability to switch Rust versions and target platforms. It’s the one official path most people use, similar in spirit to installing PHP via your OS package manager or a version manager, but unified for the whole Rust toolchain.

One installer, all platforms

Start from the official page:

https://www.rust-lang.org/tools/install

Follow the steps there for your operating system.

macOS and Linux

In a terminal, run:

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

The script will ask a few questions; the defaults (stable toolchain, standard PATH setup) are fine for this course.

After it finishes, load Rust into your current shell or open a new terminal. To load it without restarting the terminal, run:

source "$HOME/.cargo/env"

The installer usually adds a line to your shell config (~/.profile, ~/.bashrc, or ~/.zshrc) so new terminals pick up rustc and cargo automatically.

Windows

On Windows, download and run rustup-init.exe from the same install page. It installs Rust and, when needed, the Visual Studio build tools (MSVC) for linking.

Use a terminal where the Rust environment is available, Developer Command Prompt for VS works well, or follow whatever rustup-init prints at the end of the install.

Other ways to install

You can install Rust via Homebrew, your Linux distro’s packages, or similar, but rustup is recommended: updates and multiple toolchains are much easier later.

What’s next

In the next lesson, Verifying the installation, you’ll run a couple of commands to confirm rustc and cargo are on your PATH.

From PHP to Rust — Getting Started with Rust