.Net Core 2.0 asp.net 部署到阿里云 Ubuntu 16.04.3 LTS

1、用VS2017 创建一个 .net core asp.net 默认项目

2、发布Release到文件夹,注意, 增加如下一行到 csjproj文件中:<PublishWithAspNetCoreTargetManifest>false</PublishWithAspNetCoreTargetManifest>

3、在阿里云 Ubantu 上安装   .NET Core Runtime

参见:https://www.microsoft.com/net/download/linux-package-manager/ubuntu16-04/runtime-2.0.6

4、用FTP 将发布的程序上传到Ubantu,执行下面

From the command line, run dotnet <app_assembly>.dll.
In a browser, navigate to http://<serveraddress>:<port> to verify the app works on Linux.

5、发现 http://<serveraddress>:<port> 在浏览器根本打不开网页,于是 

netstat -tnl 查看端口5000是否正常

发现5000端口,只对本地127.0.0.1有效,当然我们客户端没法访问了

修改程序 Programe.cs  文件

public static IWebHost BuildWebHost(string[] args) =>
            WebHost.CreateDefaultBuilder(args)
            .UseUrls("http://*:5000")
                .UseStartup<Startup>()
                .Build();

ok,重新发布,然后再执行上面 第 4步,就可以在客户端正常打开网址页面了!

猜你喜欢

转载自www.cnblogs.com/cqupt/p/8997040.html
今日推荐