Asp.net core部署 CentOS Linux
程序员文章站
2024-01-04 15:45:58
...
1.添加配置文件
hosting.json
{
"server.urls": "http://*:8080"
}
2.编辑Program.cs文件,修改为内容如下:
public static void Main(string[] args)
{
var config = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("hosting.json", optional: true)
.Build();
var host = new WebHostBuilder()
.UseKestrel()
.UseConfiguration(config)
.UseContentRoot(Directory.GetCurrentDirectory())
.UseIISIntegration()
.UseStartup<Startup>()
.UseApplicationInsights()
.Build();
host.Run();
}
3.发布项目
右键项目-发布,选择文件夹模式。
把发布的PublishOutput文件夹压缩成zip格式,上传到CentOS服务器。
$ #解压之前上传的网站压缩文件,如果没有安装unzip,运行yum install -y unzip zip安装
$ unzip ~/dotnet/PublishOutput.zip
$ #先关闭防火墙
$ systemctl stop firewalld.service
$ #启动网站
$ cd PublishOutput
$ dotnet TestAspNetCoreWeb.dll
$ 如果报错Failed to bind to CoreCLR,运行yum install -y libunwind 和 yum install -y icu
推荐阅读
-
在Linux安装ASP.Net Core的运行时(Runtime)
-
如何优雅的利用Windows服务来部署ASP.NET Core程序
-
Asp.Net Core WebAPI+PostgreSQL部署在Docker中
-
Asp.net Core Jenkins Docker实现一键化部署的实现
-
详解NodeJs项目 CentOs linux服务器线上部署
-
.Net Core 使用 System.Drawing.Common 部署到CentOS上遇到的问题
-
CentOS 7 部署 .NET Core 环境
-
Asp.net core部署 CentOS Linux
-
.Net Core 项目发布到Linux - CentOS 7(二)用Supervisor守护netcore进程
-
Asp.net Core 初探(发布和部署Linux)