The author selected the Open Source Initiative to receive a donation as part of the Write for DOnations program.
作者选择了“ 开源倡议”作为“ Write for DOnations”计划的一部分接受捐赠。
ASP.NET Core is a high-performant, open-source framework for building modern web applications, meant to be a more modular version of Microsoft’s ASP.NET Framework. Released in 2016, it can run on several operating systems such as Linux and macOS. This enables developers to target a particular operating system for development based on design requirements. With ASP.NET Core, a developer can build any kind of web application or service irrespective of the complexity and size. Developers can also make use of Razor pages to create page-focused design working on top of the traditional Model-View-Controller (MVC) pattern.
ASP.NET Core是用于构建现代Web应用程序的高性能开放源代码框架,它是Microsoft ASP.NET Framework的模块化版本。 它于2016年发布,可以在多种操作系统上运行,例如Linux和macOS。 这使开发人员可以根据设计要求将特定的操作系统作为开发目标。 使用ASP.NET Core,开发人员可以构建任何类型的Web应用程序或服务,而不必考虑其复杂性和规模。 开发人员还可以利用Razor页面在传统的模型-视图-控制器 (MVC)模式的基础上创建以页面为中心的设计。
ASP.NET Core provides the flexibility to integrate with any front-end frameworks to handle client-side logic or consume a web service. You could, for example, build a RESTful API with ASP.NET Core and easily consume it with JavaScript frameworks such as Angular, React, and Vue.js.
ASP.NET Core提供了与任何前端框架集成的灵活性,以处理客户端逻辑或使用Web服务。 例如,您可以使用ASP.NET Core构建RESTful API,并通过Angular,React和Vue.js等JavaScript框架轻松使用它。
In this tutorial you’ll set up and deploy a production-ready ASP.NET Core application with a MySQL Server on Ubuntu 18.04 using Nginx. You will deploy a demo ASP.NET Core application similar to the application from Microsoft’s documentation and hosted on GitHub. Once deployed, the demo application will allow you to create a list of movies and store it in the database. You’ll be able to create, read, update, and delete records from the database. You can use this tutorial to deploy your own ASP.NET Core application instead; it’s possible you’ll have to implement extra steps that include generating a new migration file for your database.
在本教程中,您将使用Nginx在Ubuntu 18.04上使用MySQL服务器设置和部署可用于生产环境的ASP.NET Core应用程序。 您将部署一个演示ASP.NET Core应用程序,该应用程序类似于Microsoft文档中的应用程序,并托管在GitHub上 。 部署后,演示应用程序将允许您创建电影列表并将其存储在数据库中。 您将能够从数据库中创建,读取,更新和删除记录。 您可以使用本教程来部署自己的ASP.NET Core应用程序。 您可能必须执行额外的步骤,包括为数据库生成新的迁移文件。
You will need the following for this tutorial:
本教程将需要以下内容:
One Ubuntu 18.04 server set up by following the Ubuntu 18.04 initial server setup guide, including a non-root user with sudo
access and a firewall.
按照Ubuntu 18.04初始服务器设置指南设置一台Ubuntu 18.04服务器,其中包括具有sudo
访问权限和防火墙的非root用户。
Nginx installed by following How To Install Nginx on Ubuntu 18.04.
通过遵循如何在Ubuntu 18.04上安装Nginx来安装Nginx 。
A secured Nginx web server. You can follow this tutorial on How To Secure Nginx with Let’s Encrypt on Ubuntu 18.04.
安全的Nginx Web服务器。 您可以按照本教程的有关如何在Ubuntu 18.04上使用Let's Encrypt保护Nginx的方法 。
An A
record with your-domain
pointing to your server’s public IP address.
A
记录,其中your-domain
指向服务器的公共IP地址。
An A
record with www.your-domain
pointing to your server’s public IP address.
与www. your-domain
的A
记录www. your-domain
www. your-domain
指向您服务器的公共IP地址。
Both of the following DNS records set up for your server. You can follow this introduction to DigitalOcean DNS for details on how to add them.
为服务器设置了以下两个DNS记录。 您可以按照DigitalOcean DNS简介进行操作,以获取有关如何添加它们的详细信息。
MySQL installed by following How To Install the Latest MySQL on Ubuntu 18.04.
通过遵循如何在Ubuntu 18.04上安装最新MySQL来安装MySQL 。
A .NET Core runtime is required to successfully run a .NET Core application, so you’ll start by installing this to your machine. First, you need to register the Microsoft Key and product repository. After that, you will install the required dependencies.
成功运行.NET Core应用程序需要.NET Core运行时,因此您首先需要将其安装到计算机上。 首先,您需要注册Microsoft Key和产品存储库。 之后,您将安装所需的依赖项。
First, logged in as your new created user, make sure you’re in your root directory:
首先,以新创建的用户身份登录,确保您位于根目录中:
Next, run the following command to register the Microsoft key and product repository:
接下来,运行以下命令来注册Microsoft密钥和产品存储库:
Use dpkg
with the -i
flag to install the specified file:
将dpkg
与-i
标志一起使用以安装指定的文件:
To facilitate the installation of other packages required for your application, you will install the universe
repository with the following command:
为了方便安装应用程序所需的其他软件包,您将使用以下命令安装universe
资源库:
Next install the apt-transport
package to allow the use of repositories accessed via the HTTP Secure protocol:
接下来安装apt-transport
软件包,以允许使用通过HTTP Secure协议访问的存储库:
Now, run the following command to download the packages list from the repositories and update them to get information on the newest versions of packages and their dependencies:
现在,运行以下命令以从存储库下载软件包列表并更新它们,以获取有关软件包的最新版本及其依赖项的信息:
Finally, you can install the .NET runtime SDK with:
最后,您可以使用以下命令安装.NET运行时SDK:
You will be prompted with the details of the size of additional files that will be installed. Type Y
and hit ENTER
to continue.
系统将提示您有关将安装的其他文件的大小的详细信息。 键入Y
然后按ENTER
继续。
Now that you’re done installing the .NET Core runtime SDK on the server, you are almost ready to download the demo application from GitHub and set up the deployment configuration. But first, you’ll create the database for the application.
现在,您已经完成了在服务器上安装.NET Core运行时SDK的工作,几乎可以从GitHub下载演示应用程序并设置部署配置了。 但是首先,您将为应用程序创建数据库。
In this section, you will create a MySQL server user, create a database for the application, and grant all the necessary privileges for the new user to connect to the database from your application.
在本节中,您将创建一个MySQL服务器用户,为该应用程序创建一个数据库,并授予所有新用户从应用程序连接到数据库所需的特权。
To begin, you need to access the MySQL client using the MySQL root account as shown here:
首先,您需要使用MySQL根帐户访问MySQL客户端,如下所示:
You will be prompted to enter the root account password, set up during the prerequisite tutorial.
系统将提示您输入在先决条件教程中设置的root帐户密码。
Next, create a MySQL database for the application with:
接下来,使用以下命令为应用程序创建一个MySQL数据库:
CREATE DATABASE MovieAppDb;
创建数据库MovieAppDb ;
You will see the following output in the console:
您将在控制台中看到以下输出:
Output
Query OK, 1 row affected (0.03 sec)
You’ve now created the database successfully. Next, you will create a new MySQL user, associate them with the newly created database, and grant them all privileges.
现在,您已经成功创建了数据库。 接下来,您将创建一个新MySQL用户,将他们与新创建的数据库相关联,并授予他们所有特权。
Run the following command to create the MySQL user and password. Remember to change the username and password to something more secure:
运行以下命令以创建MySQL用户和密码。 请记住,将用户名和密码更改为更安全的方式:
CREATE USER 'movie-admin'@'localhost' IDENTIFIED BY 'password';
创建用户' movie-admin '@'localhost'由' password '标识;
You will see the following output:
您将看到以下输出:
Output
Query OK, 0 rows affected (0.02 sec)
To access a database or carry out a specific action on it, a MySQL user needs the appropriate permission. At the moment movie-admin does not have the appropriate permission over the application database.
要访问数据库或对其执行特定操作,MySQL用户需要适当的权限。 目前, movie-admin对应用程序数据库没有适当的权限。
You will change that by running the following command to grant access to movie-admin on MovieAppDb
:
您将通过运行以下命令在MovieAppDb
上授予对movie-admin的访问权限来进行MovieAppDb
:
GRANT ALL PRIVILEGES ON MovieAppDb.* TO 'movie-admin'@'localhost';
在MovieAppDb上授予所有特权。*至' movie-admin '@'localhost';
You will see the following output:
您将看到以下输出:
Output
Query OK, 0 rows affected (0.01 sec)
Now, you can reload the grant tables by running the following command to apply the changes that you just made using the flush statement:
现在,您可以通过运行以下命令以应用您刚刚使用flush语句所做的更改来重新加载授权表:
You will see the following output:
您将看到以下输出:
Output
Query OK, 0 rows affected (0.00 sec)
You are done creating a new user and granting privileges. To test if you are on track, exit the MySQL client:
完成创建新用户并授予特权的操作。 要测试您是否步入正轨,请退出MySQL客户端:
Log in again, using the credentials of the MySQL user you just created and enter the appropriate password when prompted:
使用刚刚创建MySQL用户的凭据再次登录,并在出现提示时输入适当的密码:
mysql -u movie-admin -p
mysql -u 电影管理 -p
Check to be sure that the user movie-admin can access the created database, check with:
检查以确保用户movie-admin可以访问创建的数据库,请使用以下命令进行检查:
You will see the MovieAppDb
table listed in the output:
您将在输出中看到MovieAppDb
表:
Output
+--------------------+
| Database |
+--------------------+
| MovieAppDb |
| information_schema |
+--------------------+
2 rows in set (0.01 sec)
Now, exit the MySQL client:
现在,退出MySQL客户端:
You’ve created a database, made a new MySQL user for the demo application, and granted the newly created user the right privileges to access the database. In the next section, you will start setting up the demo application.
您已经创建了一个数据库,为该演示应用程序创建了一个新MySQL用户,并为该新创建的用户授予了访问数据库的权限。 在下一部分中,您将开始设置演示应用程序。
As stated earlier, you’ll deploy an existing ASP.NET Core application. This application was built to create a movie list and it uses the Model-View-Controller design pattern to ensure a proper structure and separation of concerns. To create or add a new movie to the list, the user will populate the form fields with the appropriate details and click on the Create button to post the details to the controller. The controller at this point will receive a POST HTTP request with the submitted details and persist the data in the database through the model.
如前所述,您将部署现有的ASP.NET Core应用程序。 该应用程序是为创建影片列表而构建的,它使用“模型-视图-控制器”设计模式来确保适当的结构和关注点分离。 要创建新电影或将新电影添加到列表,用户将使用适当的详细信息填充表单字段,然后单击“ 创建”按钮将详细信息发布到控制器。 此时,控制器将接收带有提交的详细信息的POST HTTP请求,并通过模型将数据持久保存在数据库中。
You will use Git to pull the source code of this demo application from GitHub and save it in a new directory. You could also download an alternate application here if you will be deploying a different application.
您将使用Git从GitHub提取此演示应用程序的源代码并将其保存在新目录中。 如果要部署其他应用程序,也可以在此处下载备用应用程序。
To begin, create a new directory named movie-app
from the terminal by using the following command:
首先,使用以下命令在终端上创建一个名为movie-app
的新目录:
sudo mkdir -p /var/www/movie-app
须藤mkdir -p / var / www / movie-app
This will serve as the root directory for your application. Next, change the folder owner and group in order to allow a non-root user account to work with the project files:
这将作为您的应用程序的根目录。 接下来,更改文件夹所有者和组,以允许非root用户帐户使用项目文件:
sudo chown sammy:sammy /var/www/movie-app
sudo chown sammy : sammy / var / www / movie-app
Replace sammy with your sudo non-root username.
用您的sudo非root用户名替换sammy 。
Now, you can move into the parent directory and clone the application on GitHub:
现在,您可以进入父目录并在GitHub上克隆应用程序:
git clone https://github.com/do-community/movie-app-list.git movie-app
git clone https://github.com/do-community/movie-app-list.git movie-app
You will see the following output:
您将看到以下输出:
Output
Cloning into 'movie-app'...
remote: Enumerating objects: 91, done.
remote: Counting objects: 100% (91/91), done.
remote: Compressing objects: 100% (73/73), done.
remote: Total 91 (delta 13), reused 91 (delta 13), pack-reused 0
Unpacking objects: 100% (91/91), done.
You have successfully cloned the demo application from GitHub, so the next step will be to create a successful connection to the application database. You will do this by editing the ConnectionStrings
property within the appsettings.json
file and add the details of the database.
您已成功从GitHub克隆了演示应用程序,因此下一步将是创建与应用程序数据库的成功连接。 您将通过编辑appsettings.json
文件中的ConnectionStrings
属性并添加数据库详细信息来完成此操作。
Change directory into the application:
将目录更改为应用程序:
cd movie-app
cd 电影应用
Now open the file for editing:
现在打开文件进行编辑:
Add your database credentials:
添加您的数据库凭据:
{
"Logging": {
"LogLevel": {
"Default": "Warning"
}
},
"AllowedHosts": "*",
"ConnectionStrings": {
"MovieContext": "Server=localhost;User Id=movie-admin;Password=password;Database=MovieAppDb"
}
}
With this in place, you’ve successfully created a connection to your database. Now press CTRL+X
to save your changes to the file and type Y
to confirm. Then hit ENTER
to exit the page.
有了这个,您已经成功创建了到数据库的连接。 现在按CTRL+X
将更改保存到文件,然后键入Y
进行确认。 然后按ENTER
退出页面。
ASP.NET Core applications use a .NET standard library named Entity Framework (EF) Core to manage interaction with the database. Entity Framework Core is a lightweight, cross-platform version of the popular Entity Framework data access technology. It is an object-relational mapper (ORM) that enables .NET developers to work with a database using any of the database providers, such as MySQL.
ASP.NET Core应用程序使用名为实体框架 (EF)Core的.NET标准库来管理与数据库的交互。 Entity Framework Core是流行的Entity Framework数据访问技术的轻量级,跨平台版本。 它是一个对象关系映射器(ORM),使.NET开发人员可以使用任何数据库提供程序(例如MySQL)来处理数据库。
You can now update your database with the tables from the cloned demo application. Run the following command for that purpose:
现在,您可以使用克隆的演示应用程序中的表更新数据库。 为此,请运行以下命令:
This will apply an update to the database and create the appropriate schemas.
这将对数据库应用更新并创建适当的模式。
Now, to build the project and all its dependencies, run the following command:
现在,要构建项目及其所有依赖项,请运行以下命令:
You will see output similar to:
您将看到类似于以下内容的输出:
Output
Microsoft (R) Build Engine version 16.1.76+g14b0a930a7 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.
Restore completed in 95.09 ms for /var/www/movie-app/MvcMovie.csproj.
MvcMovie -> /var/www/movie-app/bin/Debug/netcoreapp2.2/MvcMovie.dll
MvcMovie -> /var/www/movie-app/bin/Debug/netcoreapp2.2/MvcMovie.Views.dll
Build succeeded.
0 Warning(s)
0 Error(s)
Time Elapsed 00:00:01.91
This will build the project and install any third-party dependencies listed in the project.assets.json
file but the application won’t be ready for production yet. To get the application ready for deployment, run the following command:
这将构建项目并安装project.assets.json
文件中列出的所有第三方依赖项,但该应用程序尚未准备好投入生产。 要使应用程序准备好进行部署,请运行以下命令:
You will see the following:
您将看到以下内容:
Output
Microsoft (R) Build Engine version 16.1.76+g14b0a930a7 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.
Restore completed in 89.62 ms for /var/www/movie-app/MvcMovie.csproj.
MvcMovie -> /var/www/movie-app/bin/Debug/netcoreapp2.2/MvcMovie.dll
MvcMovie -> /var/www/movie-app/bin/Debug/netcoreapp2.2/MvcMovie.Views.dll
MvcMovie -> /var/www/movie-app/bin/Debug/netcoreapp2.2/publish/
This will pack and compile the application, read through its dependencies, publish the resulting set of files into a folder for deployment, and produce a cross-platform .dll
file that uses the installed .NET Core runtime to run the application.
这将打包并编译该应用程序,通读其依赖性,将结果文件集发布到一个文件夹中以进行部署,并生成一个跨平台的.dll
文件,该文件使用已安装的.NET Core运行时来运行该应用程序。
By installing dependencies, creating a connection to the database, updating the database with the necessary tables, and publishing it for production, you’ve completed the setup for this demo application. In the next step you will configure the web server to make the application accessible and secure at your domain.
通过安装依赖项,创建与数据库的连接,使用必要的表更新数据库并将其发布以进行生产,您已经完成了此演示应用程序的设置。 在下一步中,您将配置Web服务器,以使该应用程序可在您的域中访问和保护。
By now, having followed the How To Secure Nginx with Let’s Encrypt tutorial, you’ll have a server block for your domain at /etc/nginx/sites-available/your_domain
with the server_name
directive already set appropriately. In this step, you will edit this server block to configure Nginx as a reverse proxy for your application. A reverse proxy is a server that sits in front of web servers and forwards every web browser’s request to those web servers. It receives all requests from the network and forwards them to a different web server.
到目前为止,按照“ 如何使用加密来保护Nginx教程”之后 ,您将在/etc/nginx/sites-available/ your_domain
拥有域的服务器块,并且已经正确设置了server_name
指令。 在此步骤中,您将编辑此服务器块,以将Nginx配置为应用程序的反向代理。 反向代理是一个位于Web服务器前面的服务器,它将每个Web浏览器的请求转发到这些Web服务器。 它接收来自网络的所有请求,并将它们转发到其他Web服务器。
In the case of an ASP.NET Core application, Kestrel is the preferred web server that is included with it by default. It is great for serving dynamic content from an ASP.NET Core application as it provides better request-processing performance and was designed to make ASP.NET as fast as possible. However, Kestrel isn’t considered a full-featured web server because it can’t manage security and serve static files, which is why it is advisable to always run it behind a web server.
对于ASP.NET Core应用程序,默认情况下, Kestrel是首选的Web服务器。 它提供了更好的请求处理性能,并且旨在使ASP.NET尽可能快地运行,因此非常适合从ASP.NET Core应用程序提供动态内容。 但是,Kestrel不被认为是功能齐全的Web服务器,因为它无法管理安全性并无法提供静态文件,因此建议始终在Web服务器后运行它。
To begin, ensure that you are within the root directory of your server:
首先,请确保您位于服务器的根目录中:
Open the server block for editing with:
使用以下命令打开服务器块进行编辑:
sudo nano /etc/nginx/sites-available/your_domain
须藤纳米/ etc / nginx / sites-available / your_domain
As detailed in the Step 4 of the How To Secure Nginx with Let’s Encrypt tutorial, if you selected option 2, Certbot will automatically configure this server block in order to redirect HTTP traffic to HTTPS with just a few modifications.
如“ 如何使用加密来保护Nginx”教程的第4步中详细介绍的那样,如果您选择了选项2,则Certbot将自动配置该服务器块,以进行少量修改即可将HTTP流量重定向到HTTPS。
Continue with the configuration by editing the first two blocks in the file to reflect the following:
通过编辑文件中的前两个块来继续配置,以反映以下内容:
server {
server_name your-domain www.your-domain;
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;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
listen [::]:443 ssl ipv6only=on; # managed by Certbot
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/your-domain/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/your-domain/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
...
The configuration in this server block will instruct Nginx to listen on port 443
, which is the standard port for websites that use SSL. Furthermore, Nginx will accept public traffic on port 443
and forward every matching request to the built-in Kestrel server at http://localhost:5000
.
该服务器块中的配置将指示Nginx监听端口443
,这是使用SSL的网站的标准端口。 此外,Nginx将在端口443
上接受公共流量,并将每个匹配的请求转发到位于http://localhost:5000
的内置Kestrel服务器。
Finally, following the server block you just edited in the file, ensure that the second server block looks like so:
最后,在您刚刚在文件中编辑的服务器块之后,确保第二个服务器块如下所示:
...
server {
if ($host = www.your-domain) {
return 301 https://$host$request_uri;
} # managed by Certbot
if ($host = your-domain) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80;
listen [::]:80;
server_name your-domain www.your-domain;
return 404; # managed by Certbot
}
This server block will redirect all requests to https://your-domain
and https://www.your-domain
to a secure HTTPS access.
该服务器块将所有请求重定向到https:// your-domain
和https://www. your-domain
https://www. your-domain
以进行安全的HTTPS访问。
Next, force Nginx to pick up the changes you’ve made to the server block by running:
接下来,强制Nginx通过运行以下命令来对服务器块进行更改:
With the Nginx configuration successfully completed, the server is fully set up to forward all HTTPS requests made to https://your-domain
on to the ASP.NET Core app running on Kestrel at http://localhost:5000
. However, Nginx isn’t set up to manage the Kestrel server process. To handle this and ensure that the Kestrel process keeps running in the background, you will use systemd
functionalities.
成功完成Nginx配置后,服务器已完全设置为将对https:// your-domain
发出的所有HTTPS请求转发到在Kestrel上运行的ASP.NET Core应用程序, http://localhost:5000
为http://localhost:5000
。 但是,未设置Nginx来管理Kestrel服务器进程。 要处理此问题并确保Kestrel进程在后台继续运行,您将使用systemd
功能。
Systemd files will allow you to manage a process by providing start, stop, restart, and log functionalities once you create a process of work called a unit.
Systemd文件将允许您通过提供启动,停止,重新启动管理的过程,一旦你创建一个名为一个单位工作的进程日志功能。
Move into the systemd
directory:
移至systemd
目录:
Create a new file for editing:
创建一个新文件进行编辑:
sudo nano movie.service
须藤nano movie.service
Add the following content to it:
向其中添加以下内容:
[Unit]
Description=Movie app
[Service]
WorkingDirectory=/var/www/movie-app
ExecStart=/usr/bin/dotnet /var/www/movie-app/bin/Debug/netcoreapp2.2/publish/MvcMovie.dll
Restart=always
RestartSec=10
SyslogIdentifier=movie
User=sammy
Environment=ASPNETCORE_ENVIRONMENT=Production
Environment=DOTNET_PRINT_TELEMETRY_MESSAGE=false
[Install]
WantedBy=multi-user.target
The configuration file specifies the location of the project’s folder with WorkingDirectory
and the command to execute at the start of the process in ExecStart
. In addition, you’ve used the RestartSec
directive to specify when to restart the systemd
service if the .NET runtime service crashes.
配置文件使用WorkingDirectory
指定项目文件夹的位置,并在ExecStart
中的过程开始时指定要执行的命令。 另外,您使用了RestartSec
指令来指定.NET运行时服务崩溃时何时重新启动systemd
服务。
Now save the file and enable the new movie service created with:
现在保存文件并启用通过以下方式创建的新电影服务:
sudo systemctl enable movie.service
sudo systemctl启用movie.service
After that, proceed to start the service and verify that it’s running by starting the service:
之后,继续启动服务,并通过启动服务来验证其正在运行:
sudo systemctl start movie.service
sudo systemctl启动movie.service
Then check its status:
然后检查其状态:
sudo systemctl status movie.service
sudo systemctl状态movie.service
You will see the following output:
您将看到以下输出:
Output
movie.service - Movie app
Loaded: loaded (/etc/systemd/system/movie.service; enabled; vendor preset: enabled)
Active: active (running) since Sun 2019-06-23 04:51:28 UTC; 11s ago
Main PID: 6038 (dotnet)
Tasks: 16 (limit: 1152)
CGroup: /system.slice/movie.service
└─6038 /usr/bin/dotnet /var/www/movie-app/bin/Debug/netcoreapp2.2/publish/MvcMovie.dll
This output gives you an overview of the current status of the movie.service
created to keep your app running. It indicates that the service is enabled and currently active.
此输出使您可以movie.service
的当前状态,该状态是为了保持应用程序运行而创建的。 它指示该服务已启用并且当前处于活动状态。
Navigate to https://your-domain
from your browser to run and test out the application.
从浏览器导航到https:// your-domain
,以运行并测试该应用程序。
You’ll see the home page for the demo application—Movie List Application.
您将看到演示应用程序的主页- 电影列表应用程序 。
With the reverse proxy configured and Kestrel managed through systemd, the web app is fully configured and can be accessed from a browser.
配置了反向代理并通过systemd管理Kestrel后,Web应用程序已完全配置,可以从浏览器进行访问。
In this tutorial, you deployed an ASP.NET Core application to an Ubuntu server. To persist and manage data, you installed and used MySQL server and used the Nginx web server as a reverse proxy to serve your application.
在本教程中,您将ASP.NET Core应用程序部署到了Ubuntu服务器。 为了持久化和管理数据,您安装并使用了MySQL服务器,并使用Nginx Web服务器作为反向代理来为您的应用程序提供服务。
Beyond this tutorial, if you’re interested in building an interactive web application using C# instead of Javascript you could try a web UI framework by Microsoft called Blazor. It is an event-driven component-based web UI for implementing logic on the client side of an ASP.NET Core application.
除了本教程之外,如果您有兴趣使用C#而不是Javascript构建交互式Web应用程序,则可以尝试使用Microsoft称为Blazor的Web UI框架。 它是一个基于事件驱动的基于组件的Web UI,用于在ASP.NET Core应用程序的客户端上实现逻辑。
If you wish to deploy your own application, you’ll need to consider other required procedures to deploy your app. The complete source code for this demo application can be found here on GitHub.
如果您希望部署自己的应用程序,则需要考虑其他必需的过程来部署您的应用程序。 可以在GitHub上找到此演示应用程序的完整源代码。
翻译自: https://www.digitalocean.com/community/tutorials/how-to-deploy-an-asp-net-core-application-with-mysql-server-using-nginx-on-ubuntu-18-04