受欢迎的博客标签

Introduction

In this tutorial you’ll set up and deploy a production-ready ASP.NET Core application with a MongoDb Server on Ubuntu 18.04 using Nginx.

Real World ASP.NET Core ubuntu。 

How it works

Remember the relationships.

One Ubuntu 18.04 server - Your server
nginx - Listens on Port 443 / 80 and forwards HTTP/S calls to your website.

A secured Nginx web server
Mongodb Redis - Keeps your app data
ASP.NET Core - Runs your app / website
Supervisor - Keeps your app running

Table of contents

 

Introduction

Part 1 -Deploying Real World ASP.NET Core on Ubuntu 18.04- Introduction (you are here)

Part 1 -Deploying Real World ASP.NET Core on Ubuntu 18.04- Introduction (you are here)

Requirements

Prepare an  Run Evironmentn for ASP.NET Core Application on Ubuntu

Running an ASP.NET Core Website on Ubuntu

 

Configure ASP.NET Core as a Background Service

 

Configure NGINX as a Reverse Proxy to ASP.NET Core

Configure the reverse proxy for secure (HTTPS) client connections

 

Part 2 - Setting up your Orchard Development Evironmentn

Deploying Real World ASP.NET Core on Ubuntu 18.04 – Part 2

Prepare ASP.NET Projects

Initial Server Setup with Ubuntu 18.04 

How To Install Nginx on Ubuntu 18.04

 

Requirements

Register Microsoft key and feed
Install the .NET Core 2.1 Runtime
Install the .NET SDK
Create a new ASP.NET Core web application
Publish and copy over the app
Install MySQL
Install Apache as reverse proxy
Configure SSL
Configure Apache
Monitoring the app
Conclusion

 

Prerequisites

1.Linux Distribution

   ubuntu 18.04-x64

   root permissions

 

Install winscp on windows

https://winscp.net/download/WinSCP-5.15.3-Setup.exe

文件传输协议 = SFTP-3
加密协议 = SSH-2
SSH实现 = OpenSSH_7.2p2 Ubuntu-4ubuntu2.4
加密算法 = aes
压缩 = 否

 

other tools:

SecureCRT+SecureFX  https://www.portablesoft.org/securecrt-securefx-legacy-versions/

 

# lsb_release -a

LSB Version:	core-9.20160110ubuntu0.2-amd64:core-9.20160110ubuntu0.2-noarch:security-9.20160110ubuntu0.2-amd64:security-9.20160110ubuntu0.2-noarch
Distributor ID:	Ubuntu
Description:	Ubuntu 16.04.4 LTS
Release:	16.04
Codename:	xenial

 

 

Install .NET Core SDK on Linux Ubuntu 16.04 - x64

This tutorial installs .Net core 2.2  on  ubuntu 18.04-x64 . For other versions of ubuntu, refer to the corresponding version of the doc.

.NET>Downloads>.NET Core>.NET Core 2.2>Linux package manager

step 1:Register Microsoft key and feed,This only needs to be done once per machine.

Before installing .NET, you'll need to register the Microsoft key, register the product repository, and install required dependencies. 

Open a terminal and run the following commands:

#wget -q https://packages.microsoft.com/config/ubuntu/16.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
#sudo dpkg -i packages-microsoft-prod.deb

 

you can read the doc https://dotnet.microsoft.com/download/linux-package-manager/ubuntu16-04/sdk-current and  run the  commands.

 

step 3.Check everything installed correctly

To make sure it works after you’ve set it up, just run:

#dotnet --version

2.2.401

#dotnet --info

 .NET Core SDK (reflecting any global.json):
 Version:   2.2.401
 Commit:    729b316c13

Runtime Environment:
 OS Name:     ubuntu
 OS Version:  16.04
 OS Platform: Linux
 RID:         ubuntu.16.04-x64
 Base Path:   /usr/share/dotnet/sdk/2.2.401/

Host (useful for support):
  Version: 2.2.6
  Commit:  7dac9b1b51

.NET Core SDKs installed:
  2.2.401 [/usr/share/dotnet/sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.All 2.2.6 [/usr/share/dotnet/shared/Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.2.6 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.2.6 [/usr/share/dotnet/shared/Microsoft.NETCore.App]

To install additional .NET Core runtimes or SDKs:
  https://aka.ms/dotnet-download

If the command runs, printing out information about dotnet, you're good to go.

step 4:Website Creation

#mkdir myapp
#cd myapp
#dotnet new web -o test
#cd test
The template "ASP.NET Core Empty" was created successfully.

Processing post-creation actions...
Running 'dotnet restore' on test1/test1.csproj...
  Restore completed in 1.03 sec for /root/myapp/test1/test1.csproj.

Restore succeeded.

The dotnet command creates a new website server application of type website for you. The -o parameter creates a directory named test where your app is stored, and populates it with the required files. The cd myApp command puts you into the newly created app directory.

step5:Run

dotnet run --urls http://localhost:5005
warn: Microsoft.AspNetCore.Server.Kestrel[0]
      Unable to bind to http://localhost:5005 on the IPv6 loopback interface: 'Cannot assign requested address'.
Hosting environment: Development
Content root path: /root/myapp/test
Now listening on: http://localhost:5005
Application started. Press Ctrl+C to shut down.

 

windows

1.dotnet publish

2.copy in\Debug\netcoreapp2.1\publish\*.* to linux  var/www/

3.cd var/www/publish

4.dotnet project.dll

 

Prerequisites for .NET Core on Linux

https://docs.microsoft.com/en-us/dotnet/core/linux-prerequisites?tabs=netcore2x