Linux 上 .NET Core 的必要條件Prerequisites for .NET Core on Linux

本文會說明在 Linux 開發 .NET Core 應用程式所需的相依性。This article shows the dependencies needed to develop .NET Core applications on Linux. 支援的 Linux 發行版本/版本和跟隨的相依性,適用於在 Linux 開發 .NET Core 應用程式的兩種方式:The supported Linux distributions/versions, and dependencies that follow apply to the two ways of developing .NET Core apps on Linux:

注意

實際執行伺服器/生產環境不需要 .NET Core SDK 套件。The .NET Core SDK package is not required for production servers/environments. 僅需要.NET Core 執行階段套件,即可將應用程式部署到生產環境。Only the .NET Core runtime package is needed for apps deployed to production environments. .NET Core 執行階段將應用程式作為獨立部署的一部分進行部署,不過,針對架構相依的部署應用程式必須單獨加以部署。The .NET Core runtime is deployed with apps as part of a self-contained deployment, however, it must be deployed for Framework-dependent deployed apps separately. 如需架構相依部署類型和獨立部署類型的詳細資訊,請參閱 .NET Core 應用程式部署For more information about framework-dependent and self-contained deployment types, see .NET Core application deployment. 另請參閱獨立式 Linux 應用程式以了解特定指導方針。Also see Self-contained Linux applications for specific guidelines.

支援的 Linux 版本Supported Linux versions

.NET Core 2.x 將 Linux 視為單一作業系統。.NET Core 2.x treats Linux as a single operating system. 針對支援的 Linux 發行版本,會有單一的 Linux 組建 (按晶片架構)。There is a single Linux build (per chip architecture) for supported Linux distributions.

如需下載連結和詳細資訊,請參閱 .NET Core 2.2 下載.NET Core 2.1 下載For download links and more information, see .NET Core 2.2 downloads or .NET Core 2.1 downloads.

下列 Linux 發行版本/版本支援 .NET core 2.x:.NET Core 2.x is supported on the following Linux distributions/versions:

  • Red Hat Enterprise Linux 7、6 - 64 位元 (x86_64amd64)Red Hat Enterprise Linux 7, 6 - 64-bit (x86_64 or amd64)
  • CentOS 7 - 64 位元 (x86_64amd64)CentOS 7 - 64-bit (x86_64 or amd64)
  • Oracle Linux 7 - 64 位元 (x86_64amd64)Oracle Linux 7 - 64-bit (x86_64 or amd64)
  • Fedora 28、27 - 64 位元 (x86_64amd64)Fedora 28, 27 - 64-bit (x86_64 or amd64)
  • Debian 9 (64 位元,arm32)、8.7 或更新版本 - 64 位元 (x86_64amd64)Debian 9 (64-bit, arm32), 8.7 or later versions - 64-bit (x86_64 or amd64)
  • Ubuntu 18.04 (64 位元 arm32)、16.04、14.04 - 64 位元 (x86_64amd64)Ubuntu 18.04 (64-bit, arm32), 16.04, 14.04 - 64-bit (x86_64 or amd64)
  • Linux Mint 18、17 - 64 位元 (x86_64amd64)Linux Mint 18, 17 - 64-bit (x86_64 or amd64)
  • openSUSE 42.3 或更新版本 - 64 位元 (x86_64amd64)openSUSE 42.3 or later versions - 64-bit (x86_64 or amd64)
  • SUSE Enterprise Linux (SLES) 12 Service Pack 2 或更新版本 - 64 位元 (x86_64amd64)SUSE Enterprise Linux (SLES) 12 Service Pack 2 or later - 64-bit (x86_64 or amd64)
  • Alpine Linux 3.7 或更新版本 - 64 位元 (x86_64amd64)Alpine Linux 3.7 or later versions - 64-bit (x86_64 or amd64)

如需 .NET Core 2.1 和 .NET Core 2.2 支援的作業系統完整清單、發行版本與版本、不支援的 OS 版本,以及生命週期原則連結,請參閱 .NET Core 2.1 支援的 OS 版本.NET Core 2.2 支援的 OS 版本See .NET Core 2.1 Supported OS Versions and .NET Core 2.2 Supported OS Versions for the complete list of .NET Core 2.1 and .NET Core 2.2 supported operating systems, distributions and versions, out of support OS versions, and lifecycle policy links.

Linux 發行版本相依性Linux distribution dependencies

下列要作為範例。The following are intended to be examples. 確切的版本和名稱在您選擇的 Linux 發行版本上可能略有出入。The exact versions and names may vary slightly on your Linux distribution of choice.

UbuntuUbuntu

Ubuntu 發行版本需要安裝下列程式庫:Ubuntu distributions require the following libraries installed:

  • liblttng-ust0liblttng-ust0
  • libcurl3 (適用於 14.x 及 16.x)libcurl3 (for 14.x and 16.x)
  • libcurl4 (適用於 18.x)libcurl4 (for 18.x)
  • libssl1.0.0libssl1.0.0
  • libkrb5-3libkrb5-3
  • zlib1gzlib1g
  • libicu52 (適用於 14.x)libicu52 (for 14.x)
  • libicu55 (適用於 16.x)libicu55 (for 16.x)
  • libicu57 (適用於 17.x)libicu57 (for 17.x)
  • libicu60 (適用於 18.x)libicu60 (for 18.x)

針對 .NET Core 2.1 之前的版本,還需要下列的相依性:For versions earlier than .NET Core 2.1, following dependencies are also required:

  • libunwind8libunwind8
  • libuuid1libuuid1

CentOS 與 FedoraCentOS and Fedora

CentOS 發行版本需要安裝下列程式庫:CentOS distributions require the following libraries installed:

  • lttng-ustlttng-ust
  • libcurllibcurl
  • openssl-libsopenssl-libs
  • krb5-libskrb5-libs
  • libiculibicu
  • zlibzlib

Fedora 使用者:如果您的 openssl 版本 >= 1.1,則必須安裝 compat-openssl10。Fedora users: If your openssl's version >= 1.1, you'll need to install compat-openssl10.

針對 .NET Core 2.1 之前的版本,還需要下列的相依性:For versions earlier than .NET Core 2.1, following dependencies are also required:

  • libunwindlibunwind
  • libuuidlibuuid

如需有關相依性的詳細資訊,請參閱獨立式 Linux 應用程式 (英文)。For more information about the dependencies, see Self-contained Linux applications.

使用原生安裝程式來安裝 .NET Core 相依性Installing .NET Core dependencies with the native installers

受支援的 Linux 發行版本/版本可使用 .NET Core 原生安裝程式。.NET Core native installers are available for supported Linux distributions/versions. 原生安裝程式需要伺服器的管理員 (sudo) 存取權。The native installers require admin (sudo) access to the server. 使用原生安裝程式的優點在於它會安裝所有的 .NET Core 原生相依性。The advantage of using a native installer is that all of the .NET Core native dependencies are installed. 原生安裝程式也會安裝 .NET Core SDK 全系統。Native installers also install the .NET Core SDK system-wide.

Linux 上有兩個安裝程式套件選擇:On Linux, there are two installer package choices:

  • 使用摘要型套件管理員,例如 Ubuntu 的 apt get 或 CentOS/RHEL 的 yum。Using a feed-based package manager, such as apt-get for Ubuntu, or yum for CentOS/RHEL.
  • 使用套件本身,DEB 或 RPM。Using the packages themselves, DEB or RPM.

使用 .NET Core 安裝程式指令碼以指令碼進行安裝Scripting Installs with the .NET Core installer script

dotnet-install 指令碼用來執行 CLI 工具鏈和共用執行階段的非 Admin 安裝。The dotnet-install scripts are used to perform a non-admin install of the CLI toolchain and the shared runtime. 您可以從 https://dot.net/v1/dotnet-install.sh 下載指令碼。You can download the script from https://dot.net/v1/dotnet-install.sh.

指令碼預設為安裝最新的 "LTS" 版本,也就是目前的 .NET Core 1.1。The script defaults to installing the latest "LTS" version, which is currently .NET Core 1.1. 若要安裝 .NET Core 2.1,請使用下列參數執行指令碼:To install .NET Core 2.1, run the script with the following switch:

./dotnet-install.sh -c Current

安裝程式 bash 指令碼是用於自動化案例和非系統管理員安裝。The installer bash script is used in automation scenarios and non-admin installations. 此指令碼也能讀取 PowerShell 參數,所以它們可以搭配 Linux/OS X 系統上的指令碼一起使用。This script also reads PowerShell switches, so they can be used with the script on Linux/OS X systems.

疑難排解Troubleshoot

如果您在支援的 Linux 發行版本/版本上安裝 .NET Core 的相關問題,請參閱已安裝之發行版本/版本的下列主題:If you have problems with a .NET Core installation on a supported Linux distribution/version, consult the following topics for your installed distributions/versions: