简体   繁体   中英

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? I have found this: https://docs.microsoft.com/en-us/aspnet/core/publishing/linuxproduction but I am stuck on this: 在此输入图像描述

I have published the application and copied it to my Ubuntu, but I have no idea how can I "run the app". 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. The doc file you link to tells you how to start your application using Systemd .

  1. Create a service definition file eg /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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM