ASP. NET Core is released to the Linux production environment Ubuntu system, coreubuntu

Source: Internet
Author: User

ASP. NET Core is released to the Linux production environment Ubuntu system, coreubuntu

ASP. NET Core is released to the Ubuntu System in the Linux production environment. We have explained the release of dotnet publish, instead of concatenating the entire system.

Today, we will give a comprehensive introduction to ASP. NET Core released to the Linux production environment.

 

Development and release environment: WIN10 x64

Production Linux environment: Ubuntu 14.04

 

Sample Code released: https://github.com/linezero/NETCoreBBS

Download the code. First, comment out. UseUrls ("http: // *: 80") in Program. cs ")

This article describes how to publish dotnet publish.

Default release

Download the sample code and go to the src \ NetCoreBBS folder.

First, dotnet restore, and then enter the dotnet publish command.

 

Built-in runtime release

Go to the src \ NetCoreBBS folder and open the project. json file.

Comment out "type": "platform"

Enter dotnet publish-r ubuntu.14.04-x64

 

Ubuntu Configuration

Upload the released folders to the ubuntu system separately. Here we recommend a tool, WinSCP.

For the default release, use dotnet NetCoreBBS. dll to install the. NET Core SDK.

For self-built runtime, Set permissions and install the corresponding dependencies, without installing the SDK, directly use./NetCoreBBS to run.

Set permissions: chmod-R 755 NetCoreBBS

1. Install. NET Core SDK

Https://www.microsoft.com/net/core#ubuntu

Ubuntu 14.04

sudo sh -c 'echo "deb [arch=amd64] https://apt-mo.trafficmanager.net/repos/dotnet/ trusty main" > /etc/apt/sources.list.d/dotnetdev.list'sudo apt-key adv --keyserver apt-mo.trafficmanager.net --recv-keys 417A0893sudo apt-get update
sudo apt-get install dotnet-dev-1.0.0-preview2-003121

After installation, you can use the dotnet command.

2. install and configure Nginx
sudo apt-get install nginx

After installation, locate the/etc/nginx/sites-available/default file. Modify the server node as follows.

server {    listen 80;    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;    }}

Then restart Nginx

sudo service nginx restart

 

3. install and configure the supervisor
sudo apt-get install supervisor

 

After the supervisor is installed, configure it as follows.

Go to the/etc/supervisor/conf. d/folder and add a NetCoreBBS. conf file.

Below is the dotnet NetCoreBBS. dll command method. After several pitfalls, the final configuration file is finally obtained. The directory must be specified because the Sqlite database is used.

[program:NetCoreBBS]command=/usr/bin/dotnet /root/publish/NetCoreBBS.dlldirectory=/root/publishautostart=trueautorestart=truestderr_logfile=/var/log/NetCoreBBS.err.logstdout_logfile=/var/log/NetCoreBBS.out.logenvironment=ASPNETCORE__ENVIRONMENT=Productionuser=rootstopsignal=INT

 

Restart the supervisor. As I put it in the root folder, the root user is required. You can also put it in other folders.

sudo service supervisor restart

 

The following is the built-in runtime mode. The first step can be omitted during the built-in runtime, without installing the SDK to install several dependencies. See previous article: http://www.cnblogs.com/linezero/p/5475246.html

[program:NetCoreBBS]command=/root/publishself/NetCoreBBSdirectory=/root/publishselfautostart=trueautorestart=truestderr_logfile=/var/log/NetCoreBBS.err.logstdout_logfile=/var/log/NetCoreBBS.out.logenvironment=ASPNETCORE__ENVIRONMENT=Productionuser=rootstopsignal=INT

 

Then we can access the configured ip address or domain name to access the ASP. NET Core site.

If you want to configure multiple sites, you can configure them in Nginx.

 

Reference: https://docs.asp.net/en/latest/publishing/linuxproduction.html

 

If you think this article is helpful to you, click"Recommendation", Thank you.

Reference page: http://qingqingquege.cnblogs.com/p/5933752.html

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.