ASP. NET Core Publishing and Deployment (Linux + Jexus)

Source: Internet
Author: User
Tags dotnet

Objective

In the previous article, I focused on the Dotnet Core Run command, which is mainly about how to publish and deploy our completed programs in ASP.

For a deployment using Nginx, see my other article:
Http://www.cnblogs.com/savorboard/p/dotnet-core-publish-nginx.html

Directory
    • Installing the LIUNX DotNet environment
    • Create a new Web project and publish
    • Using Jexus for reverse proxy
Installing the Linux DotNet environment

Install dotnet Environment See the official website Https://www.microsoft.com/net/core#ubuntu.

Create a new WEBAPP project and publish

In the ASP. NET Core project, we use the dotnet new -t WebApp command and create a new empty WEB application and then use dotnet resotre restore Nuget.

The main ones are the following commands:

mkdir HelloWebAppThe command is to create a folder named Hellowebapp.

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

After creating the application, use the dotnet restore and dotnet run commands to test our application.
Let's look at the effect by opening the browser input http://localhost:5000.

You can see that it has been successfully run.

If the application is published, we need to use dotnet publish the command to --help see some command parameters that can be used by using parameters.

-f|--framework <FRAMEWORK> Target FrameworkTo compileFor-r|--runtime <RUNTIME_IDENTIFIER> Target RuntimeTo publishFor-b|--build-base-path <OUTPUT_DIR> Directoryin which to place temporary outputs-o|--output <OUTPUT_PATH > Path in which to publish the app--version-suffix < version_suffix> defines what ' * ' should is 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 run the dotnet publish -o ~/WorkSpace/publish publish to publish folder and when you see Published 1/1 projects successfully it, the description has been published successfully.

PS: If prompted not to install NPM tool, run sudo install apt-get npm -g , first install NPM.
If prompted without the Bower administration tool, use sudo npm install bower -g install bower.
If prompted without the Gulp build tool, use sudo npm install gulp -g Install Gulp.
If the installation process is not responding, please scientific Internet after installation.

It is necessary to explain the subfolders within the Publish folder after publishing.

appsettiong.json  应用程序的配置文件refs 应用程序引用的.net fx系统程序集runtimes 运行时环境,可以看到里面的文件夹包含 win7、linxu,mac os 等,说明我们这个应用程序是跨平台的。views 这个文件夹存放的就是我们的 mvc 的视图文件。wwwroot 文件夹,存放的是前端使用的 js 库,css 样式表,和图片等。

Then use dotnet HelloWebApp.dll the test after the published program is working properly.

Using Jexus for reverse proxy
    • Jexus Introduction
    • Installing Jexus
    • Configure Jexus
    • Precautions
Jexus Introduction

Jexus is a homegrown Web server that runs on Linux. I just put the link to the specific introduction.

Official website: http://www.jexus.org/
Zhang Shanyu's introduction: http://www.cnblogs.com/shanyou/archive/2011/01/23/Jexus.html

Installing Jexus

In the Command Line window, use the following command to install a green version of Jexus (no need to install Mono 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*

Use the following command to start Jexus

cd /usr/jexussudo ./jws start

Open the browser input http://localhost if you see the following exception interface, the representative runs successfully.

Configure Jexus

There are two ways to access our Web application on Jexus. That is, the way port forwarding and reverse proxy, here are two ways to configure the method.

1. * * Port Forwarding * *

Port forwarding, which forwards the Jexus configuration port directly to our ASP. NET program, which is forwarded to Kestrel for processing.

2. * * Reverse Proxy * *

Reverse proxy, that is, a part of our application path to Jexus to deal with, such as static files, pictures and so on. Another part of the dynamic is handed over to Kertrel for processing. This can reduce the pressure on our back-end Kertrel.

Another important advantage is that the cache in the Web is handled in the proxy server step. Let's look at the following picture:

As to how to add a cache that the proxy server can recognize, follow the blog post that I posted later.

After installing Jexus as described above, the configuration file path is in the /usr/jexus/siteconf/default file.
Switch working directory to /usr/jexus/siteconf/ , use the sudo gedit default command to open the default file.
The contents of the modification are as follows:

port=80# Jexus 默认访问的工作目录root=/ /home/yxd/Workspace/publish # 下面这种方式是反向代理。我设置的路径是"/"即根目录,大家可以根据# 需要设置为非静态的路径reproxy=/ http://localhost:5000/# 下面这种方式是使用端口转发AppHost.Port=5000# 注意: 以上两种方式配置一种即可。

Save and exit. Then use the sudo ./jws restart command to reboot.

Then we opened the browser input http://localhost, found that at this time through the Jexus to visit our site.

Precautions

1. When using the Jexus proxy to access the site, the dotnet run HelloWebApp.dll command-line window that keeps the command must be turned on.

2. You can use the following command to have a command line run in a background process.

nohup dotnet HelloWebApp.dll &

You can turn off the command-line window at this time.

The next article will show you how to use Docker in Linux to deploy, and how to get out of the command-line host to our dotnet program to create a daemon, and the failure of the automatic restart, and so on ... Keep your eye on it.

If you feel that this article is helpful to you, you may wish to order a "recommendation".

This address: http://www.cnblogs.com/savorboard/p/dot-net-linux-jexus.html
Author Blog: Savorboard
Welcome reprint, please keep the source

ASP. NET Core Publishing and Deployment (Linux + Jexus)

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.