[英]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启动您的应用程序。
/etc/systemd/system/myapp.service
/etc/systemd/system/myapp.service
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
Enable the service like this: 像这样启用服务:
systemctl enable myapp.service
Start the service: 启动服务:
systemctl start myapp.service
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.