Linux安装Net 6

menglicl   ·   发表于 2022-7-5   ·   干货

以下提供主流Linux发行版本安装Net6的脚本命令,如遇到问题,请回复。

1. 以Red Hat Linux衍生的版本,如 Centos Rocky Alma

1.1 Red Hat 7.x 安装脚本

sudo subscription-manager repos --enable=rhel-7- variant -dotnet-rpms
sudo subscription-manager list --consumed
sudo yum install scl-utils -y
sudo yum install rh-dotnet60 -y
scl enable rh-dotnet60 bash

1.2 Centos 7.x 安装脚本

sudo rpm -Uvh https://packages.microsoft.com/config/centos/7/packages-microsoft-prod.rpm
sudo yum install dotnet-sdk-6.0

1.3 Centos 8.x |Red Hat [8.x|9.x] |Rocky [8.x|9.x] |Alma [8.x|9.x] 安装脚本

//由于Centos8已经终止维护,需要更换第三方仓库才能使用,个人不建议在使用Centos8,推荐转入Alma Linux 百度下有无损更换脚本
sudo yum install dotnet-sdk-6.0 -y


2. Debian安装

2.1 Debian 11.x 安装脚本

wget https://packages.microsoft.com/config/debian/11/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
rm packages-microsoft-prod.deb
sudo apt-get update; \
  sudo apt-get install -y apt-transport-https && \
  sudo apt-get update && \
  sudo apt-get install -y dotnet-sdk-6.0


2.2 Debian 10.x 安装脚本

wget https://packages.microsoft.com/config/debian/10/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
rm packages-microsoft-prod.deb
sudo apt-get update; \
  sudo apt-get install -y apt-transport-https && \
  sudo apt-get update && \
  sudo apt-get install -y dotnet-sdk-6.0

2.3 Debian 9.x 安装脚本

wget -O - https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.asc.gpg
sudo mv microsoft.asc.gpg /etc/apt/trusted.gpg.d/
wget https://packages.microsoft.com/config/debian/9/prod.list
sudo mv prod.list /etc/apt/sources.list.d/microsoft-prod.list
sudo chown root:root /etc/apt/trusted.gpg.d/microsoft.asc.gpg
sudo chown root:root /etc/apt/sources.list.d/microsoft-prod.list
sudo apt-get update; \
  sudo apt-get install -y apt-transport-https && \
  sudo apt-get update && \
  sudo apt-get install -y dotnet-sdk-6.0


3. Ubuntu安装

3.1 Ubuntu 22.x

wget https://packages.microsoft.com/config/ubuntu/22.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
rm packages-microsoft-prod.deb
sudo apt-get update; \
  sudo apt-get install -y apt-transport-https && \
  sudo apt-get update && \
  sudo apt-get install -y dotnet-sdk-6.0

3.2 Ubuntu 21.x

wget https://packages.microsoft.com/config/ubuntu/21.10/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
rm packages-microsoft-prod.deb
sudo apt-get update; \
  sudo apt-get install -y apt-transport-https && \
  sudo apt-get update && \
  sudo apt-get install -y dotnet-sdk-6.0

3.3 Ubuntu 20.x

wget https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
rm packages-microsoft-prod.deb
sudo apt-get update; \
  sudo apt-get install -y apt-transport-https && \
  sudo apt-get update && \
  sudo apt-get install -y dotnet-sdk-6.0

3.4 Ubuntu 18.x

wget https://packages.microsoft.com/config/ubuntu/18.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
rm packages-microsoft-prod.deb
sudo apt-get update; \
  sudo apt-get install -y apt-transport-https && \
  sudo apt-get update && \
  sudo apt-get install -y dotnet-sdk-6.0

3.5 Ubuntu 16.x

wget https://packages.microsoft.com/config/ubuntu/16.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
rm packages-microsoft-prod.deb
sudo apt-get update; \
  sudo apt-get install -y apt-transport-https && \
  sudo apt-get update && \
  sudo apt-get install -y dotnet-sdk-6.0

4. 其他发行版本安装

4.1 Fedora 安装(仅支持 34.x版本以上)

sudo dnf install dotnet-sdk-6.0

4.2 Arch 安装

sudo pacman -S dotnet-sdk

4.3 openSUSE 安装 15.x以上版本

sudo zypper install libicu
sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc
wget https://packages.microsoft.com/config/opensuse/15/prod.repo
sudo mv prod.repo /etc/zypp/repos.d/microsoft-prod.repo
sudo chown root:root /etc/zypp/repos.d/microsoft-prod.repo
sudo zypper install dotnet-sdk-6.0

4.4 SLES 12 SP2 15.x

//15.x 安装
sudo rpm -Uvh https://packages.microsoft.com/config/sles/15/packages-microsoft-prod.rpm
sudo ln -s /etc/yum.repos.d/microsoft-prod.repo /etc/zypp/repos.d/microsoft-prod.repo
sudo zypper install dotnet-sdk-6.0
//12.x 安装
sudo rpm -Uvh https://packages.microsoft.com/config/sles/12/packages-microsoft-prod.rpm
sudo zypper install dotnet-sdk-6.0

如果还有未列出可以留言告知.

5. 检查是否安装好

dotnet --info

如果回显下图证明安装成功,否则失败。(随着程序的更新版本号可能有变化.)

image.png

打赏我,让我更有动力~

0 Reply   |  Until 2022-7-5 | 327 View
LoginCan Publish Content
每日签到
0人
连续签到0天