How to deploy DoNetCore to Alibaba Cloud with Nginx

How to deploy DoNetCore to Alibaba Cloud with Nginx

Basic environment configuration

Please purchase the domain name and server by yourself first

Create an application instance based on the cloud server ECS, select the system image as Ubuntu 16.04, connect remotely via SSH on the local machine, and perform relevant configurations
ssh root@http://39.108.48.203/

...

sudo apt-get update
sudp apt-get upgrade
sudo apt-get autoremove
sudo apt-get clean

Install and configure Nginx

sudo apt-get install nginx
sudo service nginx start
sudo gedit /etc/nginx/sites-available/default

Configure the default file and configure the following node information at the end of the file

# Virtual Host configuration for example.com
#
# You can move that to a different file under sites-available/ and symlink that
# to sites-enabled/ to enable it.
#
server {
 listen 80;
 # The target location of the website files is root /home/hippie/website/wwwroot;
 # server_name your website name;
  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;
   proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
   proxy_set_header X-Forwarded-Proto $scheme;
 }
}

Check configuration and update

sudo nginx -t
sudo nginx -s reload

Install DotNetCore

Please refer to the latest installation instructions on the official website: .NetCore Download

Deployment Process

Open VisualStudio2017, right-click the project to be published, click Publish, and refer to the figure below for relevant configuration.

Click the Save button to publish. Then upload the publish folder to the corresponding location on the server. After the upload is successful, execute
dotnet run app.dll

If nothing goes wrong, at this time, you can access it through IP or your website domain name.

Creating a daemon process

After performing the above operations, our program still cannot run for a long time, so we need to manage our website through a daemon process

sudo apt-get install supervisor
sudo vim /ect/supervisor/conf.d/website.conf

Configure website.conf file

[program:website]
#Command to execute command=/usr/bin/dotnet Attention.dll 
#Command execution directory directory=/home/hippie/website 
#Environment variable environment=ASPNETCORE__ENVIRONMENT=Production 
 #Process execution user identity user=www-data 
stopsignal=INT
#Whether to start automatically autostart=true
#Whether to automatically restart autorestart=true
#Automatic restart interval startsecs=1 
#Standard error log stderr_logfile=/var/log/website.err.log 
#Standard output log stdout_logfile=/var/log/website.out.log

At this time, we execute the following command to start the daemon process

sudo supervisorctl shutdown && sudo supervisord -c /etc/supervisor/supervisord.conf
supervisorctl shutdown 
sudo service supervisor start

Well, now you can try to close the remote connection to access the website. If you can access it normally, it means that your configuration has worked.

Summarize

The above is the installation and configuration method that I introduced to you for deploying DoNetCore to Alibaba Cloud in combination with Nginx. I hope it will be helpful to you. If you have any questions, please leave me a message and I will reply to you in time!

You may also be interested in:
  • Alibaba Cloud Deployment of Ubuntu 1.4 Flask + WSGI + Nginx Detailed Explanation
  • Detailed steps to deploy https on Alibaba Cloud using nginx + node
  • How to deploy Vue project on nginx (history mode)
  • Record the entire process of Angular project from creation, packaging to nginx deployment
  • Docker for Beginners and Detailed Steps for Deploying NGINX
  • Docker builds Nginx+PHP+MySQL environment and deploys WordPress practice
  • Detailed explanation of how Nginx + Tomcat reverse proxy can efficiently deploy multiple sites on one server

<<:  Solve the problem that await does not work in forEach

>>:  MySQL trigger detailed explanation and simple example

Recommend

Example code of implementing starry sky animation with CSS3 advanced LESS

This article introduces the sample code of advanc...

Detailed analysis of GUID display issues in Mongodb

Find the problem I recently migrated the storage ...

MySQL database connection exception summary (worth collecting)

I found a strange problem when deploying the proj...

Installation and daemon configuration of Redis on Windows and Linux

# Installation daemon configuration for Redis on ...

Solve the problem of Docker starting Elasticsearch7.x and reporting an error

Using the Docker run command docker run -d -p 920...

Detailed explanation of the usage of two types of temporary tables in MySQL

External temporary tables A temporary table creat...

Docker solves the problem that the terminal cannot input Chinese

Preface: One day, I built a MySQL service in Dock...

How to modify the length limit of group_concat in Mysql

In MySQL, there is a function called "group_...

Solve the problem of inconsistency between mysql time and system time in docker

Recently, when I installed MySQL in Docker, I fou...

vsCode generates vue templates with one click

1. Use the shortcut Ctrl + Shift + P to call out ...

Example of using docker compose to build a consul cluster environment

Basic concepts of consul Server mode and client m...

Why the table file size remains unchanged after deleting data in MySQL

For databases that have been running for a long t...

How to create a MySQL master-slave database using Docker on MacOS

1. Pull the MySQL image Get the latest MySQL imag...