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

Source: Internet
Author: User
Tags dotnet sqlite database

ASP. NET Core released to the Linux production environment Ubuntu system, before you explained the dotnet publish release, but not the whole system to string up.

Today, let's talk about ASP. NET core released to the Linux production environment.

Development and release environment: WIN10 x64

Production Linux environment: Ubuntu 14.04

Sample code for publishing: Https://github.com/linezero/NETCoreBBS

Code download down, first please comment Program.cs. Useurls ("http://*:80")

This article will be published dotnet publish two ways to do the introduction.

Default Publishing

Download the sample code and navigate to the Src\netcorebbs folder.

First dotnet Restore, and then enter the dotnet Publish command.

Bring your own runtime publishing

Navigate to the Src\netcorebbs folder and open the Project.json file.

Comment out "type": "Platform"

First the same dotnet restore, then enter dotnet publish-r ubuntu.14.04-x64

Ubuntu Configuration

Upload the folder you just published to the Ubuntu system, where we recommend a tool WinSCP.

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

For the own runtime, set permissions, and install the corresponding dependencies, without installing the SDK, directly using the./netcorebbs run.

Set permissions: Chmod-r 755 Netcorebbs

1. Install the. NET Core SDK

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

Ubuntu 14.04

sudo SH ' 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 Install dotnet-dev-1.0. 0-preview2-003121

Once installed, you can use the dotnet command.

2. Install and configure Nginx
sudo Install Nginx

Once installed, navigate to the/etc/nginx/sites-available/default file. Change the server node as follows.

server {    a;     / {        proxy_pass http://localhost:5000;        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 the Nginx

sudo service nginx restart

3. Installation and Configuration Supervisor
sudo Install Supervisor

After installing the supervisor, the following configuration is to be done.

Navigate to the/etc/supervisor/conf.d/folder and add a netcorebbs.conf file.

Here's how the dotnet NetCoreBBS.dll command works. After many pits, finally get the final configuration file. This is because you need to specify a directory for the SQLite database.

[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 Supervisor, here because I placed in the root folder, so need root user, everyone can also be placed in other folders.

sudo service supervisor Restart

The following is the own run-time mode, with the runtime can omit the first step, without installing the SDK install several dependencies on the line. Refer to the 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 access the IP or domain name set to access the ASP.

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

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

If you think this article is helpful to you, please click " recommend ", thank you.

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

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.