asp.net core deploys centos7 nginx reverse proxy binding domain name

     I recently learned asp.net core, and I can't wait to deploy it online. According to some online tutorials, some inexplicable errors always occur. After reinstalling the system 10+ times and operating it dozens of times, I finally deployed it and recorded it with a blog. , so that you can find it later

          Install the .net sdk under centos7 (for the server, you can install the runtime. But for convenience, install the sdk directly. I have experienced all kinds of inexplicable problems when installing the runtime, and I gave up in tears)

     The addresses of each version of runtime and sdk: https://www.microsoft.com/net/download/all   

site1 : install dotnet-sdk

      To start installing .NET, you need to sign up for a Microsoft signing key and add the Microsoft product feed. This only needs to be done once on each machine.

   Open a command prompt and run the following commands:

  sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc 
  sudo 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”

     Install .NET SDK

  Update the products available for installation, install the components required for .NET, and then install the .NET SDK.

   From your command prompt, run the following commands:   

    sudo yum update 
    sudo yum install libunwind libicu 
    sudo yum install dotnet-sdk-2.1.105

site2 : install Nginx

    Add Nginx download source to yum:

      sudo rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm


    安装Nginx
    sudo yum install -y nginx

site3 : connect to centos server with xftp. Edit Nginx.conf configuration

    Download xftp, connect to centos with xftp, find nginx.conf in /etc/nginx, open it with an editor, modify the server, cd to the nginx directory to start Nginx, enter the command nginx

        

server {
    listen 80;
    server_name xxxxx.com; #domain name
    location / {
        proxy_pass http: // localhost:5000; //Started asp.net core process 
        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;
    }

    

 

site4 : start

      Publish the asp.net core project to the file system, open the directory copy file, upload it to centos with xftp, cd command to the current directory of the project, use the command: nohup dotnet HelloWebApp .dll & (start in the background, so you can close the command window )

 

  

 
  

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325623271&siteId=291194637