Asp. Net Core Release and deployment (Linux + Jexus)

Source: Internet
Author: User

Asp. Net Core Release and deployment (Linux + Jexus)
Preface

In the previous article, we mainly introduced the Dotnet Core Run command. This article mainly explains how to release and deploy our completed programs in asp.net core.

For more information about how to deploy Nginx, see my own article:

Directory
  • Install the Liunx DotNet Environment
  • Create and release a Web Project
  • Use Jexus for reverse proxy
Install the Linux DotNet Environment

To install the dotnet environment, see the official website https://www.microsoft.com/net/core?ubuntu.

Create a WebApp project and publish it

In the Asp. Net Core project, we usedotnet new -t WebAppCommand and create a new empty Web application, and then usedotnet resotreRestore Nuget.

The following commands are used:

mkdir HelloWebAppThis command is used to create a folder named HelloWebApp.

dotnet new -t WebThis command uses a Web template to create a WebApp Mvc application.

After creating an application, usedotnet restoreAnddotnet runCommand to test our application.
Enter http: // localhost: 5000 in the browser to check the effect.

You can see that the operation is successful.

To publish an application, we need to usedotnet publishCommand, by using--helpYou can see some command parameters that can be used.

  -f|--framework <FRAMEWORK>          Target framework to compile for    -r|--runtime <RUNTIME_IDENTIFIER>   Target runtime to publish for    -b|--build-base-path <OUTPUT_DIR>   Directory in which to place temporary outputs    -o|--output <OUTPUT_PATH>           Path in which to publish the app    --version-suffix <VERSION_SUFFIX>   Defines what `*` should be replaced with in version field in project.json    -c|--configuration <CONFIGURATION>  Configuration under which to build    --native-subdirectory               Temporary mechanism to include subdirectories from native assets of dependency packages in output    --no-build                          Do not build projects before publishing

We rundotnet publish -o ~/WorkSpace/publishPublish to the publish folder.Published 1/1 projects successfullyThe release is successful.

PS: If the NPM tool is not installed, runsudo install apt-get npm -gInstall NPM first.
If you are prompted that the bower management tool is not available, usesudo npm install bower -gInstall bower.
If you are prompted that there is no gulp build tool, usesudo npm install gulp -gInstall gulp.
If no response is received during installation, go to the Internet to install the SDK.

It is necessary to describe the subfolders In the publish folder after publishing.

Appsettiong. json application configuration file referenced by the refs application. net fx system assembly runtimes runtime environment, you can see that the folder contains win7, linxu, mac OS, and so on, this shows that our application is cross-platform. The views folder stores our mvc view files. The wwwroot folder stores the js library, css style sheets, and images used by the front end.

Then usedotnet HelloWebApp.dllTest whether the released program runs normally.

Use Jexus for reverse proxy
  • Jexus Introduction
  • Install Jexus
  • Configure Jexus
  • Notes
Jexus Introduction

Jexus is a domestic Web server running on Linux. For details, I just put the link.

Official Website: http://www.jexus.org/
Introduction of Zhang Shanyou:

Install Jexus

In the command line window, run the following command to install a green version of jexus (Mono does not need to be installed separately ).

cd /tmpwget linuxdot.net/down/jexus-5.8.1-x64.tar.gztar -zxvf jexus-5.8.1-x64.tar.gzsudo mv jexus /usrsudo rm -rf /tmp/jexus*

Run the following command to start jexus

cd /usr/jexussudo ./jws start

Open the browser and enter http: // localhost. If the following exception interface is displayed, the operation is successful.

Configure Jexus

There are two ways to access our Web application on Jexus. That is, the port forwarding and reverse proxy methods. The following are two configuration methods.

1. ** port forwarding **

Port forwarding means that the port configured in Jexus is directly forwarded to our asp.net program, that is, forwarded to Kestrel for processing.

2. ** reverse proxy **

A reverse proxy is used to send a part of the path of our application to Jexus for processing, such as static files and images. The other part is dynamically handled by Kertrel. This reduces the pressure on our backend Kertrel.

Another important advantage is that the cache in the Web will be processed on the proxy server. Let's take a look at the figure below:

As for how to add a cache that can be recognized by the proxy server, follow the blog post I published later.

After Jexus is installed/usr/jexus/siteconf/defaultFile.
Switch the working directory/usr/jexus/siteconf/, Usesudo gedit defaultCommand to open the default file.
The modified content is as follows:

Port = 80 # Jexus default access to the working directory root = // home/yxd/Workspace/publish # the following method is reverse proxy. The path I set is "/", that is, the root directory. You can set the non-static path reproxy =/http: // localhost: 5000/# the following method uses port forwarding to AppHost. port = 5000 # Note: Configure one of the above two methods.

Save and exit. Then usesudo ./jws restartCommand to restart.

Then we open the browser and enter http: // localhost. We found that we have accessed our site through jexus.

Notes

1. When using the jexus proxy to access the site, keep the commanddotnet run HelloWebApp.dllThe command line window of must be enabled.

2. Run the following command to run a command line in the background process.

nohup dotnet HelloWebApp.dll &

In this case, you can close the command line window.

The next article will explain how to use Docker for deployment in Linux, how to create a daemon for our dotnet program from the command line host, and how to automatically restart when the machine fails... See.

This article permanently updates the link address:

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.