How to set up Linux server for asp.net core 2 web app and make it visible on internet? Part 3 [Music no 3]

How to  publish site with Visual Studio 2017 to Linux server:

 

sudo apt-get update

sudo apt-get install openssh-server unzip curl

Y

 

  1. Go to VS2017 and hit publish on project:
  2.  Set up debug mode on publish:
  3. Download WINSCP. https://winscp.net/eng/download.php
  4. Create new folder for your app.
  5. Copy all stuf from publish folder to new create folder on server
  6. In Putty go folder where you have copied your app:
    cd //go out from myApp
    
    cd Music
    
    dotnet Musiction.API.dll //publish app
    

    You should to see

    Hosting environment: Production
    Content root path: /root/Music
    Now listening on: http://localhost:5000

  7. Your site is up and running on server, but it is not visible on internet. Open new Putty
    sudo apt-get install nginx
    
    Y
  8. Go to /etc/nginx/sites-available/default. and replace content to:
    server {
        listen 80;
        server_name   1.services.oktawave.com *.1.services.oktawave.com;
        location / {
            proxy_pass http://localhost:5000;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection keep-alive;
            proxy_set_header Host $host;
            proxy_cache_bypass $http_upgrade;
        }
    }
  9. Run nginx
    sudo nginx -t //verify if the syntax of the configuration files is correct
    
    sudo service nginx start
  10. Your site is visible on the internet under address: 1.services.oktawave.com/api/songs/ :)/

 

 

 

https://blogs.msdn.microsoft.com/premier_developer/2017/11/10/debugging-asp-core-on-linux-with-visual-studio-2017/

https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/linux-nginx?view=aspnetcore-2.1&tabs=aspnetcore2x

Leave a Comment

Twój adres email nie zostanie opublikowany. Pola, których wypełnienie jest wymagane, są oznaczone symbolem *