Beginner's introductory "ASP. NET Core" 4: Install the. Core runtime on CentOS, deploy to CentOS

Source: Internet
Author: User
Tags dotnet

Download the. NET Core SDK

: Https://www.microsoft.com/net/download/windows

First step: Add the dotnet product feed (adding dotnet products)

To start installing. NET, your ' ll need to register the Microsoft signature key and add the Microsoft Product feed. This is needs to is done once per machine. Open a command prompt and run the following commands (to start installing. NET, you need to register the Microsoft signing key and add the Microsoft product feed. This only needs to be done once per machine. Open a command prompt and run the following command)

sudo rpm--import https://packages.microsoft.com/keys/microsoft.ascsudo sh-c ' Echo-e "[packages-microsoft-com-prod]\ Nname=packages-microsoft-com-prod \nbaseurl= https://packages.microsoft.com/yumrepos/microsoft-rhel7.3-prod\ Nenabled=1\ngpgcheck=1\ngpgkey=https://packages.microsoft.com/keys/microsoft.asc ">/etc/yum.repos.d/ Dotnetdev.repo '
Step two: Install the. NET SDK (installing the. NET SDK)

Update the product available for installation and install the components required by. NET and then install the. NET SDK. (More Products available Install the installation components, and then install the required. Net,.net SDK. )

sudo yum updatesudo yum install libunwind libicusudo yum install dotnet-sdk-2.0.2

After the installation is complete, we can execute the dotnet console command to create the Dotnet project.

Create a core project

Execute dotnet New--help command at the command line view Create Help

Then execute dotnet new webapi-n hellocore Create Webapi Project

Execute CD hellocore command to enter Hellocore folder

Execute dotnet Run running WEBAPI, you can see Webapi now running on port 5000

Access Http://192.168.110.129:5000/cannot be accessed at this time because the port is not open

This time the program has been running, it is impossible to say stop the service after the open, and then restart

It's our practice here to restart a putty.

Then perform curl http://localhost:5000/api/values to see if the API is accessible

Deploy the Hellovs project to CentOS

Before publishing the VS created Hellovs project to the folder, then we need to use a FileZilla tool to upload the file to CentOS

Enter \home in the remote site to access the home folder, and then create the Netcore folder under the home folder

Then select the Published folder and upload all the files in the folder.

After the transfer is complete we continue to use the Putty software to see if the file was uploaded successfully

This is the time to execute dotnet HelloVS.dll run the content we published

Workaround for the above problems:

Note that the Dotnet SDK on the current platform is not 2.0.3, execute the following command:

sudo yum install dotnet-sdk-2.0.3

Once the installation is complete, run HelloVS.dll again

Access 5000-Port Curl http://localhost:5000 with putty

Here you can see that the site is already accessible

Nginx Map Port

Enter the Nginx installation directory Cd/etc/nginx

View nginx.conf

You can see the default. All *.conf files are introduced in

At first there is a default 80 port configuration, and we're going to comment it out.

After commenting

This time into the CONF.D folder found there is no file

At this point we create a netcore.conf file that forwards the 80 port to 5000 counterpart

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

Perform nginx-s reload or systemctl restart Nginx to restart Nginx after configuration is complete

Then access port 80

This time the visit found it possible to report 502, find a long way to find a solution

Cause: SELinux configuration issues.
Workaround: Turn off SELinux.
Input: sestatus , if SELinux status: enabled , indicates on, enter vi /etc/selinux/config modify configuration: selinux=disabled.

Or

CentOS: Add Nginx to SELinux's Allow list

Yum Install Policycoreutils-python

Cat/var/log/audit/audit.log | grep Nginx | grep denied | Audit2allow-m Mynginx

Semodule-i mynginx.pp

Then restart the CentOS

Beginner's introductory "ASP. NET Core" 4: Install the. Core runtime on CentOS, deploy to CentOS

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.