Introduction
In this tutorial you’ll set up and deploy a production-ready ASP.NET Core application with a MongoDb Server on Ubuntu 22.04 using Nginx.
Real World ASP.NET Core ubuntu。
How it works
Remember the relationships.
One Ubuntu 22.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
Quick Start
sudo apt update
sudo apt install nginx
sudo snap install --classic certbot
sudo ln -s /snap/bin/certbot /usr/bin/certbot
sudo ufw status
sudo ufw allow http
sudo ufw allow https
service nginx stop
netnet.club www.netnet.club
service nginx restart
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 22.04
How To Install Nginx on Ubuntu 22.04
lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 22.04.4 LTS
Release: 22.04
Codename: jammy
Requirements
upgrade from Ubuntu 20.04 LTS to 22.04 LTS detail
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 Mongodb 7.0 detail
Install Nginx as reverse proxy detail
Configure Nginx
Configure SSL
Monitoring the app
Install cerbot detail
Install nginx 1.18.0 detail
Install Certbot 2.11.0
ufw allow http
ufw allow https
#Use Certbot Standalone Mode to Retrieve Let's Encrypt SSL Certificates on Ubuntu 22.04
certbot certonly --standalone --register-unsafely-without-email
Install frp 0.45
sudo ufw allow port
Install Mongodb
Install Redis
Conclusion
Prerequisites
1.Linux Distribution
ubuntu 18.04-x64
root permissions
# lsb_release -a
LSB Version: core-11.1.0ubuntu4-noarch:security-11.1.0ubuntu4-noarch
Distributor ID: Ubuntu
Description: Ubuntu 22.04.4 LTS
Release: 22.04
Codename: jammy
Install .NET Core SDK on Linux Ubuntu 22.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
[40m[1m[33mwarn[39m[22m[49m: 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
https://miniblog.iaspnetcore.com/ on vultr direct