Configuring the. Net Core 2 Environment on Ubuntu16.04

Source: Internet
Author: User
Tags dotnet gpg

First, install the. Net Core SDK

Follow the official documentation to install the SDK by executing the following command

Curl HTTPS://PACKAGES.MICROSOFT.COM/KEYS/MICROSOFT.ASC | GPG--dearmor > MICROSOFT.GPG

sudo mv MICROSOFT.GPG/ETC/APT/TRUSTED.GPG.D/MICROSOFT.GPG

sudo sh-c ' echo ' Deb [ARCH=AMD64] https://packages.microsoft.com/repos/microsoft-ubuntu-xenial-prod xenial main ">/ Etc/apt/sources.list.d/dotnetdev.list '

sudo apt-get install Apt-transport-https

sudo apt-get update

sudo apt-get install dotnet-sdk-2.1.103

Second, create a console output program

[Email protected]:/# mkdir codes//1. Create a Codes folder

[Email protected]:/codes# dotnet New Console-o myApp//2. Create a codes project in the Cosole folder specify the project type as the console project location in the MYAPP directory

[Email protected]:/codes/myapp# dotnet run//3. Go to the MYAPP directory.

The following are the template (project) types:

Third, use Nginx Agent to publish MVC Project 1, first build an MVC project

[Email protected]:/codes# dotnet New mvc-o MVC//1. Create an MVC program that specifies the file location under the MVC folder.

[Email protected]:/codes/mvc# dotnet restore//2. Restoring dependencies

[Email protected]:/codes/mvc# dotnet Run//3.

The default listening port is 5000. CTRL + C ends the run.

2. Installing Nginx

sudo apt-get install Nginx

sudo service Ngnix Start services appears in the figure below, indicating that Nginx installation was successful.

Modify the/etc/nginx/sites-available/default file to:

Exit save, and then execute

sudo nginx-t

sudo nginx-c/etc/nginx/nginx.conf

sudo nginx-s reload

In this case, start the project in the MVC project folder, enter the IP in the browser, and if it goes well, the Web interface will appear.

The System.IO.IOException:Failed to bind to address http://[::]:80:address already on use may be reported halfway.

The reason may be to open the Nignx multiple times, execute killall-9 nginx will kill all Nginx, and then restart the Nginx service.

Configuring the. Net Core 2 Environment on Ubuntu16.04

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.