简体   繁体   English

如何在Ubuntu上运行已经开发的ASP.NET Core应用程序?

[英]How to run already developed ASP.NET Core app on Ubuntu?

What is the easiest way to run my existing ASP.NET Core application on Ubuntu? 在Ubuntu上运行现有ASP.NET Core应用程序的最简单方法是什么? I have found this: https://docs.microsoft.com/en-us/aspnet/core/publishing/linuxproduction but I am stuck on this: 我发现了这个: https//docs.microsoft.com/en-us/aspnet/core/publishing/linuxproduction但我坚持这个: 在此输入图像描述

I have published the application and copied it to my Ubuntu, but I have no idea how can I "run the app". 我已经发布了应用程序并将其复制到我的Ubuntu,但我不知道如何“运行应用程序”。 Any help will be really appreciated. 任何帮助将非常感激。

It's really as simple as executing: 它真的像执行一样简单:

dotnet path/to/your/application.dll

However, for a website you really want to manage that with some sort of init system. 但是,对于一个你真的想通过某种init系统来管理它的网站。 The doc file you link to tells you how to start your application using Systemd . 您链接到的doc文件告诉您如何使用Systemd启动您的应用程序。

  1. Create a service definition file eg /etc/systemd/system/myapp.service 创建服务定义文件,例如/etc/systemd/system/myapp.service
  2. Edit the file to look like this, replacing the relevant parts where necessary: 编辑文件如下所示,在必要时替换相关部分:

     [Unit] Description=Example .NET Web API Application running on Ubuntu [Service] WorkingDirectory=/var/path/to/your/app ExecStart=/usr/bin/dotnet /var/path/to/your/app/hellomvc.dll Restart=always RestartSec=10 # Restart service after 10 seconds if dotnet service crashes SyslogIdentifier=dotnet-example User=www-data Environment=ASPNETCORE_ENVIRONMENT=Production [Install] WantedBy=multi-user.target 
  3. Enable the service like this: 像这样启用服务:

     systemctl enable myapp.service 
  4. Start the service: 启动服务:

     systemctl start myapp.service 
  5. Check if your service is running: 检查您的服务是否正在运行:

     systemctl status myapp.service 

If you have another init system, the instructions will of course be quite different. 如果你有另一个init系统,说明书当然会有很大不同。

Note: This only starts the app running on your machine. 注意:这只会启动您计算机上运行的应用。 If you intend to serve it to the public, then it is highly recommended that you use a proxy such as Nginx as Microsoft has not yet certified Kestrel as an edge server. 如果您打算向公众提供服务,那么强烈建议您使用Nginx等代理,因为Microsoft尚未将Kestrel认证为边缘服务器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何确定asp.net核心应用程序将在哪个环境中运行? - How to determine which environment asp.net core app will run in? Raspberry PI 上 Ubuntu 上的 ASP.NET Core 应用程序 - ASP.NET Core app on Ubuntu on Raspberry PI Ubuntu上的ASP.NET Core 2.2 Web应用程序 - 如何实现数据保护 - ASP.NET Core 2.2 web app on Ubuntu - how to implement Data Protection 从asp.net核心控制台应用程序运行网站 - Run Website from asp.net core console app ASP.Net Core应用程序可在Visual Studio中运行,但不能与dotnet运行 - ASP.Net Core app works in visual studio but not with dotnet run 如何在用ASP.NET开发的Azure Web应用程序上获取客户端的IP地址? - How to get client's IP address on an Azure Web App developed in ASP.NET? 在 asp.net 核心应用程序中实现了 IHostedService,如何在没有 IIS 的第一个请求的情况下运行它? - Implemented IHostedService in an asp.net core app, How to run it without the first request on IIS? c#文件更改后如何自动运行asp.net核心应用 - How to run asp.net core app automatically after changes in c# files 如何在Ubuntu上运行依赖于NuGet包的.net Core应用程序 - How to run .net Core app that depends on NuGet packages on Ubuntu 如何集成测试依赖于独立Asp.Net Core Api的Asp.Net Core客户端应用程序 - How to integration test an Asp.Net Core client app that relies on independent Asp.Net Core Api
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM