一、Linux .NET Core简介
一直以来,微软只对自家平台提供.NET支持,这样等于让这个“理论上”可以跨平台的框架在Linux和macOS上的支持只能由第三方项目提供(比如Mono .NET)。
直到微软推出完全开源的.NET Core。这个开源的平台兼容.NET Standard,并且能在Windows、Linux和MacOS上提供完全一致的API。虽然这个小巧的.NET框架只是标准.NET的一个子集,但是已经相当强大了。
一方面,这个小巧的框架可以让某些功能性应用同时运行在三个平台上(就像某些功能性的Python脚本一样),另一方面,这也可以让服务器运维人员将ASP .NET服务程序部署在Linux服务器上(特别是对于运行Windows Server较为吃力的服务器)。
官网参考资料:https://www.microsoft.com/net/core#linuxcentos
二、Linux .NET Core2.0 环境部署前准备
1.环境说明:
服务器系统:CentOS 7.2.1511
2.安装前准备(关闭防火墙、关闭selinux)
1)关闭firewall:
| systemctl stop firewalld.service #停止firewall systemctl disable firewalld.service #禁止firewall开机启动 firewall-cmd --state #查看默认防火墙状态(关闭后显示notrunning,开启后显示running) |
2)关闭selinux
| sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config |
查看改后文件如下:
| [root@localhost ~]# cat /etc/selinux/config # This file controls the state of SELinux on the system. # SELINUX= can take one of these three values: # enforcing - SELinux security policy is enforced. # permissive - SELinux prints warnings instead of enforcing. # disabled - No SELinux policy is loaded. SELINUX=disabled # SELINUXTYPE= can take one of three two values: # targeted - Targeted processes are protected, # minimum - Modification of targeted policy. Only selected processes are protected. # mls - Multi Level Security protection. SELINUXTYPE=targeted |
3)重启Centos
| reboot |
三、Centos 部署.NET Core2.0 环境
1.添加DOTNET产品
在安装.NET核心之前,您需要注册微软产品提要。这只需要做一次。首先,注册微软签名密钥,然后添加微软产品提要。
| rpm --import https://packages.microsoft.com/keys/microsoft.asc sh -c 'echo -e "[packages-microsoft-com-prod]nname=packages-microsoft-com-prod nbaseurl=https://packages.microsoft.com/yumrepos/microsoft-rhel7.3-prodnenabled=1ngpgcheck=1ngpgkey=https://packages.microsoft.com/keys/microsoft.asc" > /etc/yum.repos.d/dotnetdev.repo' |
2.安装.NET核心SDK
在下一步之前,请从您的系统中删除.NET .NET以前的任何预览版本。
以下命令更新用于安装的产品列表,安装.NET核心所需的组件,然后安装.NET核心SDK。








