"Selfless sharing: ASP. NET Core Project Combat (chapter tenth)" Launch project to Linux running CORE project

Source: Internet
Author: User
Tags dotnet

Catalog Index 

"Selfless sharing: ASP. NET CORE Project Combat" Catalog Index

Introduction

  

The biggest highlight of the ASP. NET Core is the cross-platform, I built a CentOS7 on my Computer (Win7) with a virtual machine to demonstrate how the projects on our Windows publish the project to run on Linux. I have a program built on windows, we mainly show how to run on Linux, so let's not dwell on these, you can create a new Web project to try.

  

installing the. NET Core SDK for CentOS

Microsoft has detailed installation commands and can refer to the install . NET Core SDK

  ① installation Libicu dependencies: sudo yum install libunwind Libicu

  

Installation succeeded:

  

② Download SDK compression pack:Curl-ssl-o dotnet.tar.gz https://go.microsoft.com/fwlink/?LinkID=809131

  ③ extract:sudo mkdir-p/opt/dotnet && sudo tar zxf dotnet.tar.gz-c/opt/dotnet

  

  ④ Creating a connection:sudo ln-s/opt/dotnet/dotnet/usr/local/bin

  

test whether the installation was successful

  by dotnet--info to see, the following interface appears, indicating success:

  

Test Project Run

  Note: Friends who are not familiar with Linux please note that the Liunx path is directory-case-sensitive.

  ① Create a new directory:mkdir TestApp

  

  ② Entry directory:CD TestApp

  

  ③ Create a new default Web project:dotnet new-t Web

  

  ④ Recovery package:dotnet Restore

  This time may be longer, look at the speed, we have to wait patiently.

  

  ⑤ Let's run it:dotnet Run

  

publish our project to Linux

  You can use FTP and other ways to publish the file to the server, I publish it directly to the local folder, and then sent to the server via FileZilla.

  There are several ways to publish a project, such as using the dotnet publish command, where we use VS :

  First, we open Project.json to add several releases of the runtime ( This step can not, if not configured here, then the release is any, we will talk about later )

  

  

  Then, right-click on our project and select Publish:

  

  Create a new publish profile, publish method Select File system :

  

  setting, we select Target Runtime:centos.7-x64 ( above, we talked about adding several runtimes in Project.json, if there is no one, then there is no option, only oneany)

  

  Then click Publish and we upload the published file to CentOS : I put it in the Wwwroot directory .

  

  

  Let's compile our files:dotnet XXX.dll

  Here's an error for everyone: my wkmvc.dll is in the Wwwroot directory, so I execute the command (note the path case, Linux case-sensitive, as we mentioned above) dotnet Wwwroot/wkmvc.dll

  

  

  The display succeeds, we open the browser, enter localhost:5000

  

  is blank, we modify our program, output a log to see:

  

  What is the reason for this? Why didn't you find index.cshtml? Please pay attention again to our content root path, the answer is that she does not have access to root, we will compare our installation process to test the success of the Web and our web Content roo T path

  

  Let's try it: we go into the wwwroot directory and execute dotnet wkmvc.dll

  

  

  We open the browser again, enter localhost:5000

  

  OK, let's go to the login page of our area to test it:

  

  

  No problem, the project is running successfully, but in practice we may have to install Nginx , configure our FireWall , and configure the daemon service . Supervisor and so on, this is not a demonstration.

I want to learn from you. ASP.

Just beginning to contact, the level is limited, a lot of things are their own understanding and flipping through the online god of information, if there are wrong places and do not understand the place, I hope you correct!

Although ASP. NET Core is now very hot, but many of the online information is the copy of the previous article, so there are a lot of problems I have not resolved, I hope we can help together!

Original article reproduced please respect the fruits of labor http://yuangang.cnblogs.com

"Selfless sharing: ASP. NET Core Project Combat (chapter tenth)" Launch project to Linux running CORE project

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.