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

Introduction to general_log log knowledge points in MySQL

The following operation demonstrations are all ba...

In-depth understanding of asynchronous waiting in Javascript

In this article, we’ll explore how async/await is...

How to add links to FLASH in HTML and make it compatible with all major browsers

Look at the code first Copy code The code is as fo...

Docker-compose creates a bridge, adds a subnet, and deletes a network card

1. Create a docker network card [root@i ~]# brctl...

JavaScript tips to help you improve your coding skills

Table of contents 1. Filter unique values 2. Shor...

React.js framework Redux basic case detailed explanation

react.js framework Redux https://github.com/react...

Detailed explanation of JS homology strategy and CSRF

Table of contents Overview Same Origin Policy (SO...

linux exa command (better file display experience than ls)

Install Follow the README to install The document...

Rules for registration form design

I finished reading "Patterns for Sign Up &...

Detailed explanation of the benefits of PNG in various network image formats

BMP is an image file format that is independent o...