Windows Server 安装指南Windows Server Installation Guide

适用于 Windows Server 2019 及更高版本Applies to Windows Server 2019 and later

在 //Build2017,Microsoft 宣布适用于 Linux 的 Windows 子系统将在 Windows Server 上提供At //Build2017, Microsoft announced that Windows Subsystem for Linux will be available on Windows Server. 这些说明将介绍如何在 Windows Server 1709 及更高版本上运行适用于 Linux 的 Windows 子系统。These instructions walk through running the Windows Subsystem for Linux on Windows Server 1709 and later.

启用适用于 Linux 的 Windows 子系统 (WSL)Enable the Windows Subsystem for Linux (WSL)

在 Windows 上运行 Linux 发行版之前,您必须启用“适用于 Linux 的 Windows 的子系统”可选功能并重新启动。Before you can run Linux distros on Windows, you must enable the "Windows Subsystem for Linux" optional feature and reboot.

  1. 以管理员身份打开 PowerShell 并运行:Open PowerShell as Administrator and run:

    Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
    
  2. 出现提示时重新启动计算机。Restart your computer when prompted. 必须重新启动,这是为了确保 WSL 可以启动受信任的执行环境。This reboot is required in order to ensure that WSL can initiate a trusted execution environment.

下载 Linux 发行版Download a Linux distro

请按照这些说明下载您最喜爱的 Linux 发行版。Follow these instructions to download your favorite Linux distribution.

提取并安装 Linux 发行版Extract and install a Linux distro

下载发行版后,请提取其内容,并手动安装发行版:Now that you've downloaded a distro, extract its contents and manually install the distro:

  1. <distro>.appx提取包的内容,例如,使用 PowerShell:Extract the <distro>.appx package's contents, e.g. using PowerShell:

    Rename-Item ./Ubuntu.appx ./Ubuntu.zip
    Expand-Archive ./Ubuntu.zip ./Ubuntu
    
  2. 运行发行版启动器以完成安装,并在名为<distro>.exe的目标文件夹中运行发行版启动器应用程序。Run the distro launcher To complete installation, run the distro launcher application in the target folder, named <distro>.exe. 例如: ubuntu.exe等。For example: ubuntu.exe, etc.

    Windows Server 上的扩展 Ubuntu 发行版

    疑难解答Troubleshooting

    • 安装失败,出现错误 0x8007007e:当你的系统不支持 WSL 时,会出现此错误。Installation failed with error 0x8007007e: This error occurs when your system doesn't support WSL. 请确保:Make sure that:
  3. 将你的发行版路径添加到 Windows 环境路径 (在此示例中为C:\Users\Administrator\Ubuntu),例如,使用 Powershell:Add your distro path to the Windows environment PATH (C:\Users\Administrator\Ubuntu in this example), e.g. using Powershell:

    $userenv = [System.Environment]::GetEnvironmentVariable("Path", "User")
    [System.Environment]::SetEnvironmentVariable("PATH", $userenv + ";C:\Users\Administrator\Ubuntu", "User")
    

    您现在可以通过键入<distro>.exe从任何路径启动发行版。You can now launch your distro from any path by typing <distro>.exe. 例如: ubuntu.exeFor example: ubuntu.exe

安装 Linux 发行版后,您必须在使用发行版之前初始化新的发行版实例Now that your Linux distro is installed, you must initialize your new distro instance before using your distro.