1.linux安装 ASP.NET Core 5.0运行时,用sudo dnf install aspnetcore-runtime-5.0命令进行安装,安装完成后,经过 sudo dotnet --info 验证是否安装成功。linux
2.用FolderProfile(文件)发布asp.net core 5.0的webapi程序,目标框架是net5.0,目标运行时选中linux-x64,进行保存并发布web
3.将发布后的文件夹进行打包,打包成rar格式,并利用MobaXterm上传该压缩包至链接的linux的文件中,建立一个net文件夹并进入该目录,利用命令 rar x WebApiDemo.rar 进行解压缩解压缩。json
4.执行dotnet WebApiDemo.dll --urls http://*:5000命令,出现如下提示说明webapi服务已经运行,访问http://localhost:5000便可。api
5.若提示404,上图最后一行提示Failed to determine the https port for redirect,说明建立的webapi项目配置了https,只要注释掉Startup中的app.UseHttpsRedirection();以及删除launchSetting.json中的https://localhost:5001并发
6.若用其余终端访问改端口,须要暴露linux的端口。app
firewall-cmd --zone=public --add-port=5000/tcp --permanent 开启端口外网访问框架
firewall-cmd --reload 更新防火墙规则asp.net