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 .
/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.
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.