4

What is the easiest way to run my existing ASP.NET Core application on Ubuntu? I have found this: https://learn.microsoft.com/en-us/aspnet/core/publishing/linuxproduction but I am stuck on this: enter image description here

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.

8
  • Scroll down in that doc file, it tell you how to start it later on... Commented Apr 25, 2017 at 15:31
  • But it says that is should work now Commented Apr 25, 2017 at 15:33
  • Have you created a service definition and started it? Commented Apr 25, 2017 at 15:33
  • have you installed the .NET Core runtime for Ubuntu yet? Commented Apr 25, 2017 at 15:35
  • Yes I have installed .NET Core on Ubuntu, I just don't know how to run the already published application Commented Apr 25, 2017 at 15:37

1 Answer 1

5

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

Sign up to request clarification or add additional context in comments.

3 Comments

Thank you, I will try it and when it works I will mark this answer :)
@meziantou You should really point out that it's your blog when posting things like that. Especially when you've already posted it an hour ago on the question.
I wrote on my blog a step by step guide to publish an ASP.NET Core website on Ubuntu

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.