Centos+nginx+supervisor Deploying ASP. NET Core Project

Source: Internet
Author: User
Tags dotnet net command net command line

The study and practice of. NET core has been in the world for more than a year, and as of Now, Microsoft has released. NET Core2.1, and articles about. Netcore application deployment abound. Take this today to review the deployment process for the. NET core environment.

First, my side is on the centos7+ version,. NET core2.1. Before we do this, we think about it first.

How do I deploy a formal. NET core2.1 project?

The solutions are:

1. Use the. NET core runtime and the. NET Core SDK, publish the compiled project to the server, and then run the dotnet application.dll command.

This process works, but to make the. NET core process always exists, you need to do something else, such as the more Supervisor Daemon service on the web, which guarantees. NET core programs that can still run after the terminal is closed.

2, the use of cross-platform server Jexus.

3. Use Docker container technology to run the. NET core program in a Docker container.

Sure, there are other solutions, such as Nancy, and there's no further elaboration.

Next, we will use the Supervisor service developed by Python to protect the. NET core process for the first way.

Then, we think again, when the daemon installation configuration is complete, we then install a Web server, such as nginx as a proxy server for. NET core programs.

As a result, in this practice, we need to install configuration. NET Core, supervisor, Nginx, and so on, then we will describe the configuration of these three environments separately:

1.. NET Core Installation

This can be found on the official website for further instructions Https://www.microsoft.com/net/learn/get-started-with-dotnet-tutorial

The first is to download the package:

sudo rpm-uvh https://packages.microsoft.com/config/rhel/7/packages-microsoft-prod.rpm

The. NET Core SDK is then installed with the Yum command (the. NET core runtime is also installed when the SDK is installed).

sudo yum updatesudo yum install dotnet-sdk-2.1

Wait for the installation to complete. Version information can be viewed through the dotnet--info/--version command.

[Email protected] ~]# dotnet--Info. NET Command Line Tools (2.1.101) Product information:version:2.1.101Commit SHA-1hash:6c22303bf0runtime environment:os name:centos OS Version:7OS platform:linux Rid:centos.7-x64 Base Path:/usr/share/dotnet/sdk/2.1.101/Microsoft. NET Core Shared Framework Host Version:2.0.6build:74b1c703813c8910df5b96f304b0f2b78cdf194d

This allows the. NET core2.1 environment to be installed.

2, the installation of Supervisor service.

This specific reference to my other blog https://my.oschina.net/lichaoqiang/blog/1861791

3, installation of Nginx

Here, we are installing directly through the Yum command.

The first is to download the package management

RPM-UVH http://nginx.org/packages/centos/7/noarch/rpms/nginx-release-centos-7-0.el7.ngx.noarch.rpm 

Installing Nginx via Yum

Yum Install Nginx

Start Nginx Service

Systemctl start Nginx.servicesystemctl Enable Nginx.service

By default, the Nginx configuration file is in the/etc/nginx/directory. command to enter the/ETC/NGINX/CONF.D folder to create a configuration file for our. NET Core application

Server {Listen80;server_name www.demo.com;#charset koi8-r;#access_log/var/log/nginx/host.access.log Main;Location /{Proxy_pass http://localhost:5000;Index index.html index.htm;} #error_page404/404.html;# REDIRECT Server error pages to the static page/50x.html # Error_page502 503 504/50x.html;Location =/50x.html {root/usr/share/nginx/html;} # Proxy The PHP scripts to Apache listening on127.0.0.1:80# #location ~ \.php$ {# Proxy_pass/HTTP /127.0.0.1;#} # Pass the PHP scripts to FastCGI server listening on127.0.0.1:9000# #location ~ \.php$ {# root HTML;# Fastcgi_pass 127.0.0.1:9000;# Fastcgi_index index.php;# Fastcgi_param Script_filename/scripts$fastcgi_script_name;# include Fastcgi_params;#} # Deny access to. htaccess files,if Apache ' s document Root # concurs with Nginx's one # #location ~/\.ht {# deny all;    #}}

Then reload the configuration file:

/usr/nginx/sbin/nginx/-S Reload

After completing the three steps above, we supervisorctl restart application. dll.

Finally, by publishing our. NET core project with the VS release feature, avoid the problem that NuGet references the package, and when we release it, the target runtime is selected linux-x64.

About the. NET core deployment formal environment is described here.

Centos+nginx+supervisor Deploying ASP. NET Core Project

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.