asp.net core 2.1 部署 centos7

Kestrel 非常适合从 ASP.NET Core 提供动态内容。 但是,Web 服务功能不像服务器(如 IIS、Apache 或 Nginx)那样功能丰富。 反向代理服务器可以从 HTTP 服务器卸载服务静态内容、缓存请求、压缩请求和 SSL 终端等工作。 反向代理服务器可能驻留在专用计算机上,也可能与 HTTP 服务器一起部署。

鉴于此指南的目的,使用 Nginx 的单个实例。 它与 HTTP 服务器一起运行在同一服务器上。

  • 参考文档
  1. 官方文档
  • 64位安装SDK所需依赖
  1. yum update
  2. yum -y install libunwind
  3. yum -y install libicu
  • 注册微软产品密钥
  1. 执行 sudo rpm -Uvh https://packages.microsoft.com/config/rhel/7/packages-microsoft-prod.rpm
  • 安装SDK/runtime
  1. yum -y install dotnet-sdk-2.1 或 yum -y install aspnetcore-runtime-2.1
  • 检测安装
  1. 执行 dotnet --info,验证安装结果,如下:

.NET Core SDK (reflecting any global.json):


Version: 2.1.401

Commit: 91b1c13032

Runtime Environment:

OS Name: centos

OS Version: 7

OS Platform: Linux

RID: centos.7-x64

Base Path: /usr/share/dotnet/sdk/2.1.401/

...

  • 创建并允许实例
  1. 创建MVC应用程序 X:\mvcApp2 dotnet new mvc
  2. 本地运行(win10) dotnet run
  3. 浏览器访问
  4. 发布linux程序 dotnet publish -c Release -o "XX:\Web_IIS\mvcApp2" -r centos.7-x64

.net core运行时标识符

  1. xftp上传文件到指定目录 /home/doetnetcore/mvcApp2
  2. 运行程序 cd /home/dotnetcore/mvcApp2 dotnet mvcApp2.dll 如图:默认启用5000端口

  3. centos7 外部计算机若无法访问,请检查网络防火墙(即使关闭防火墙端口默认只开放22)
  4. 检查站点运行情况 curl http://localhost:5000

curl命令介绍

  1. 查看防火墙状态 firewall-cmd --state //running 表示运行

附防火墙相关命令

启动: systemctl start firewalld

查看状态:systemctl status firewalld

停止:systemctl disable firewalld

禁用:systemctl stop firewalld

启动服务:systemctl start firewalld.service

关闭服务:systemctl stop firewalld.service

重启服务:systemctl restart firewalld.service

服务的状态:systemctl status firewalld.service

在开机时启用一个服务:systemctl enable firewalld.service

在开机时禁用一个服务:systemctl disable firewalld.service

查看服务是否开机启动:systemctl is-enabled firewalld.service

查看已启动的服务列表:systemctl list-unit-files|grep enabled

查看启动失败的服务列表:systemctl --failed

查看版本: firewall-cmd --version

查看帮助: firewall-cmd --help

显示状态: firewall-cmd --state

查看所有打开的端口: firewall-cmd --zone=public --list-ports

更新防火墙规则: firewall-cmd --reload

查看区域信息: firewall-cmd --get-active-zones

查看指定接口所属区域: firewall-cmd --get-zone-of-interface=eth0

拒绝所有包:firewall-cmd --panic-on

取消拒绝状态: firewall-cmd --panic-off

查看是否拒绝: firewall-cmd --query-panic

  • 配置Nginx转发
  1. 安装Nginx

命令 curl -o nginx.rpm http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm

rpm -ivh nginx.rpm

yum install nginx

  1. 检查端口占用情况 yum install net-tools netstat -a //端口列表
  2. 启动 nginx

命令:systemctl start nginx


设置开机启动 systemctl enable nginx

firewall-cmd --zone=public --add-port=80/tcp --permanent(永久启用80端口)

重启防火墙 systemctl restart firewalld

浏览器测试nginx能否正常访问

  1. 修改nginx配置文件

yum -y install vim 可用默认vi替代

修改 /etc/nginx/conf.d/default.conf 文件。

通过 vim /etc/nginx/conf.d/default.conf 打开,编辑里面的内容,保存时按 Esc 再输入 :wq! 命令保存退出

修改为如下脚本:

 server {
listen 80;
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;
}
}
  1. 启动站点 浏览器正常访问asp.netcore 应用程序
  2. Nginx参考文献

http://nginx.org/en/docs/

http://tengine.taobao.org/book/index.html

其他参考文档:https://yq.aliyun.com/articles/584510

  • 配置守护服务(Supervisor)

  • 配置Apache转发

  1. 参考文档

asp.net core 2.1 部署 centos7的更多相关文章

  1. (转) 将ASP.NET Core应用程序部署至生产环境中(CentOS7)

    原文链接: http://www.cnblogs.com/ants/p/5732337.html 阅读目录 环境说明 准备你的ASP.NET Core应用程序 安装CentOS7 安装.NET Cor ...

  2. 将ASP.NET Core应用程序部署至生产环境中(CentOS7)(转)

    阅读目录 环境说明 准备你的ASP.NET Core应用程序 安装CentOS7 安装.NET Core SDK for CentOS7. 部署ASP.NET Core应用程序 配置Nginx 配置守 ...

  3. Asp.Net Core在CentOS部署与注意

    部署具体步骤参考:将ASP.NET Core应用程序部署至生产环境中(CentOS7) 1.wwwroot是放静态文件的,Startup的配置里面要app.UseStaticFiles(); 2.在不 ...

  4. ASP.NET Core开发-Docker部署运行

    ASP.NET Core开发Docker部署,.NET Core支持Docker 部署运行.我们将ASP.NET Core 部署在Docker 上运行. 大家可能都见识过Docker ,今天我们就详细 ...

  5. ASP.NET Core 1.0 部署 HTTPS (.NET Framework 4.5.1)

    var appInsights=window.appInsights||function(config){ function r(config){t[config]=function(){var i= ...

  6. ASP.NET Core 1.0 部署 HTTPS

    ASP.NET Core 1.0 部署 HTTPS ASP.NET Core 1.0 部署 HTTPS (.NET Framework 4.5.1) 提示 更新时间:2016年01月23日. 在目前介 ...

  7. ASP.NET Core开发期间部署到IIS自定义主机域名并附加进程调试

    在.NET Framework环境下,我们经常会这么做 把一个web项目不经过发布直接部署到IIS里去,配置上主机名,修改一下hosts文件,就可以用自定义的域名来访问我们的应用程序,使用附加到进程( ...

  8. asp.net core 2.1 部署IIS(win10/win7)

    asp.net core 2.1 部署IIS(win10/win7) 概述 与ASP.NET时代不同,ASP.NET Core不再是由IIS工作进程(w3wp.exe)托管,而是使用自托管Web服务器 ...

  9. ASP.NET Core托管和部署Linux实操演练手册

    一.课程介绍 ASP.NET Core 是一种全新的跨平台开源 .NET 框架,能够在 IIS.Nginx.Apache.Docker 上进行托管或在自己的进程中进行自托管. 作为一个.NET Web ...

随机推荐

  1. [Swift]LeetCode129. 求根到叶子节点数字之和 | Sum Root to Leaf Numbers

    Given a binary tree containing digits from 0-9 only, each root-to-leaf path could represent a number ...

  2. [Swift]LeetCode314. 二叉树的竖直遍历 $ Binary Tree Vertical Order Traversal

    Given a binary tree, return the vertical order traversal of its nodes' values. (ie, from top to bott ...

  3. [Swift]LeetCode503. 下一个更大元素 II | Next Greater Element II

    Given a circular array (the next element of the last element is the first element of the array), pri ...

  4. spring aspect获取抽象基类日志

    在实际的项目开发过程中我们其实封装了很多的类似BaseService.BaseDao等的基类,然后在切日志的时候我们一般是指向继承改抽象基类的实现类的,这时候我们就会出现无法切出调用抽象基类方法的日志 ...

  5. 【机器学习】--线性回归中soft-max从初始到应用

    一.前述 Soft-Max是做多分类的,本身是哪个类别的概率大,结果就为对应的类别.为什么称之为Soft判别,原因是归一化之后的概率选择最大的作为结果,而不是只根据分子. 二.原理 sigmod函数: ...

  6. performance数据

    // 获取 performance 数据 var performance = { // memory 是非标准属性,只在 Chrome 有 // 财富问题:我有多少内存 memory: { usedJ ...

  7. 学生选课系统 c语言

    /********************************* *主题:学生选修课程系统设计 * *设计要求: *1.添加功能:程序能够任意添加课程和学生记录,可提供选择界面供用户选择所需要添加 ...

  8. Mac电脑C语言开发的入门帖

    本文是写给Mac电脑开发新手的入门帖,诸神请退散. C语言 C语言可说是电脑环境中的"镇国神器",从发明至今,虽然C语言的使用者缓慢的减少,但从当前市场应用情况看,尚无一台电脑能够 ...

  9. Lucene 08 - 什么是Lucene的相关度排序 + Java API调整相关度

    目录 1 什么是相关度 2 相关度评分 3 相关度设置 3.1 更改相关度的需求 3.2 实现需求-设置广告 1 什么是相关度 概念: 相关度指两个事物之间的关联关系(相关性). Lucene中指的是 ...

  10. 当你「ping 一下」的时候,你知道它背后的逻辑吗?

    我们在遇到网络不通的情况,大家都知道去 ping 一下,看一下网络状况.那你知道「ping」命令后背的逻辑是什么吗?知道它是如何实现的吗? 一.「ping」命令的作用和原理? 简单来说,「ping」是 ...