[原创]Centos7 安装配置ASP.NET Core+Nginx+Supervisor
序言
此教程安装的都是最新版本的。
一键安装
有了这个神器,下面的教程就不用做了!只需运行几行代码,直接打开浏览器就可以访问!
cd /home/
wget https://files.cnblogs.com/files/project/install.sh
chmod install.sh
./install.sh
准备工作
1. 更新系统
没啥,就他喵想用个最新的。
apt update && apt upgrade
2. 创建目录
创建目录,分别用来放配置文件和网站。
mkdir /web/
一、ASP.NET Core
官方网站:https://docs.microsoft.com/zh-cn/dotnet/core/install/linux-package-manager-debian10
1. 注册Microsoft密钥和订阅源
wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.asc.gpg
sudo mv microsoft.asc.gpg /etc/apt/trusted.gpg.d/
wget -q https://packages.microsoft.com/config/debian/10/prod.list
sudo mv prod.list /etc/apt/sources.list.d/microsoft-prod.list
sudo chown root:root /etc/apt/trusted.gpg.d/microsoft.asc.gpg
sudo chown root:root /etc/apt/sources.list.d/microsoft-prod.list
2. 安装.NET Core SDK
sudo apt-get update
sudo apt-get install apt-transport-https
sudo apt-get update
sudo apt-get install dotnet-sdk-3.1
3. 利用.NET Core SDK创建一个web实例
创建 Web 应用项目
cd /web/
dotnet new webapp -o app
二、Supervisor
官方网站:http://www.supervisord.org/
1. 安装Supervisor
apt install -y supervisor
2. 编辑supervisord.conf
vim /etc/supervisor/supervisord.conf
3. 新建配置文件
将下面配置文件存到/etc/supervisor/conf.d/app.conf
[program:app]
command=dotnet run ;要执行的命令
directory=/web/app/ ;命令执行的目录
autostart=true ;是否自动启动
autorestart=true ;是否自动重启
stderr_logfile=/var/log/webapp.err.log ;标准错误日志
stdout_logfile=/var/log/webapp.out.log ;标准输出日志
4. 重新启动
supervisorctl shutdown
supervisord -c /etc/supervisor/supervisord.conf
四、Nginx
官方网站:http://nginx.org/
1. 安装nginx
apt install -y nginx
2. 编辑nginx.conf
vim /etc/nginx/nginx.conf
3. 修改如下
worker_processes ;
events {
worker_connections ;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout ;
gzip on;
server {
listen ;
server_name localhost;
location / {
proxy_pass https://localhost:5001;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection keep-alive;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_cache_bypass $http_upgrade;
}
}
}
4. 重新加载
nginx -s reload
五、效果预览

附、常用命令
nginx
# nginx //启动nginx
# nginx -s reload //重启nginx
# nginx -s stop //关闭nginx
supervisor
supervisord
supervisorctl status //查看所有任务状态
supervisorctl shutdown //关闭所有任务
supervisorctl start|stop|restart all //控制所有进程
supervisorctl start|stop|restart program_name //控制目标进程
[原创]Centos7 安装配置ASP.NET Core+Nginx+Supervisor的更多相关文章
- CentOS7上部署ASP.Net Core 2.2应用
前言 在CentOS7上部署ASP.Net Core应用是我的技术路线验证的一部分,下一个产品计划采用ASP.Net Boilerplate Framework开发.因此需要求提前进行一下技术验证,在 ...
- 部署Asp.net core & Nginx,通过nginx转发
部署Asp.net core & Nginx,通过nginx转发 CentOS 7 x64 1.vs2017 建立Asp.net core项目,并发布到目录 2.通过FTP工具,将程序copy ...
- 本文演示如何配置ASP.NET Core项目以在Visual Studio(VS)2017中使用Telerik UI for ASP.NET Core。
学习时使用的是VS2017+Core2.1了,不再讨论VS2015和core1.1的东西. 配置ASP.NET Core Web应用程序以使用Telerik UI for ASP.NET Core: ...
- ASP.NET Core Identity 配置 - ASP.NET Core 基础教程 - 简单教程,简单编程
原文:ASP.NET Core Identity 配置 - ASP.NET Core 基础教程 - 简单教程,简单编程 ASP.NET Core Identity 配置 上一章节我们简单介绍了下 Id ...
- ASP.NET Core macOS 环境配置 - ASP.NET Core 基础教程 - 简单教程,简单编程
原文:ASP.NET Core macOS 环境配置 - ASP.NET Core 基础教程 - 简单教程,简单编程 ASP.NET Core 是对 ASP.NET 有重大意义的一次重新设计.本章节我 ...
- ASP.NET Core Windows 环境配置 - ASP.NET Core 基础教程 - 简单教程,简单编程
原文:ASP.NET Core Windows 环境配置 - ASP.NET Core 基础教程 - 简单教程,简单编程 ASP.NET Core Windows 环境配置 ASP.NET Core ...
- CentOS7 安装配置笔记
CentOS7 安装配置笔记 1.通过镜像安装 CentOS7 ==============================* 使用 UltraISO 9.7 或者 rufus-3.5p 制作ISO的 ...
- 用"hosting.json"配置ASP.NET Core站点的Hosting环境
通常我们在 Prgram.cs 中使用硬编码的方式配置 ASP.NET Core 站点的 Hosting 环境,最常用的就是 .UseUrls() . public class Program { p ...
- 阿里云服务器Linux CentOS安装配置(八)nginx安装、配置、域名绑定
阿里云服务器Linux CentOS安装配置(八)nginx安装.配置.域名绑定 1.安装nginx yum -y install nginx 2.启动nginx service nginx star ...
随机推荐
- Vue中添加过渡效果
最近在学习Vue这个框架,发现新的版本中,官网的文档里面说的过渡效果,如果直接粘贴官方的例子中的代码,发现并没有过渡的效果,经过反复测试之后终于知道怎么搞了,把测试的过程总结一下,以便以后回顾. 贴上 ...
- Buy or Build UVA - 1151 Kruskal+枚举
题意: 大概意思是有 n 个点,现在有 q 个方案 ,第 i 个方案耗费为 ci ,使 Ni 个点联通 ,当然也可以直接使两点联通 ,现求最小生成树的代价. 两点直接联通的代价是欧几里得距离的平方: ...
- Android自动化----adb shell,appium,uiautomator2
1.区别 1,adb shell脚本的方式 不但可以在有电脑的情况下使用,通过数据线连接电脑然后adb shell命令,而且还可以打包成app,在手机的终端使用adb shell命令. 2,appiu ...
- zabbix发送邮件脚本
#!/usr/bin/env python #-*- coding: UTF- -*- import os,sys reload(sys) sys.setdefaultencoding('utf8') ...
- angularJs分层服务开发
//控制层 app.controller('brandController' ,function($scope,$controller ,brandService){ $controller('bas ...
- LUNA16数据集(一)简介
LUNA16,全称Lung Nodule Analysis 16,是16年推出的一个肺部结节检测数据集,旨在作为评估各种CAD(computer aid detection计算机辅助检测系统)的ban ...
- CMD 有关知识点
java的Runtime.getRuntime().exec(commandStr)可以调用执行cmd指令. cmd /c dir 是执行完dir命令后关闭命令窗口. cmd /k dir 是执行完d ...
- mysql 存储引擎介绍
一 存储引擎解释 首先确定一点,存储引擎的概念是MySQL里面才有的,不是所有的关系型数据库都有存储引擎这个概念,后面我们还会说,但是现在要确定这一点. 在讲清楚什么是存储引擎之前,我们先来个比喻, ...
- 4.AOP
1.代理模式 代理模式(Proxy Pattern)是GoF23种常用设计模式之一使用代理模式创建代理对象,让代理对象控制目标对象的访问,并且可以在不改变目标对象的情况下添加一些额外的功能包括静态代理 ...
- Problem01 不死神兔
题目:有一对兔子,从出生后第3个月起每个月都生一对兔子,小兔子长到第三个月后每个月又生一对兔子,假如兔子都不死,问每个月的兔子对数为多少? 程序分析:兔子的规律为数列1,1,2,3,5,8,13,21 ...