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]LeetCode265.粉刷房子 II $ Paint House II

    There are a row of n houses, each house can be painted with one of the k colors. The cost of paintin ...

  2. [Swift]LeetCode309. 最佳买卖股票时机含冷冻期 | Best Time to Buy and Sell Stock with Cooldown

    Say you have an array for which the ith element is the price of a given stock on day i. Design an al ...

  3. [Swift]LeetCode552. 学生出勤记录 II | Student Attendance Record II

    Given a positive integer n, return the number of all possible attendance records with length n, whic ...

  4. MySQL数据库导入或者同步大量数据时数据丢失解决方案

    相信大家都经常遇到这样的情况,我们在编码的过程中经常需要在调试代码的时候切换到本地的数据库上做修改调试,如果当测试数据库的数据在几十万或者上百万数据的时候,我们无论是通过恢复备份/导入SQL的方式来把 ...

  5. 巡风源码阅读与分析--querylogic函数

    文件位置:views/lib/QueryLogic.py Querylogic() # 搜索逻辑 def querylogic(list): query = {} if len(list) > ...

  6. 【mysql】mysql 调优之 ——执行计划 explain

    1.what is explain(explain 是个什么东东) explain(解释),在 Mysql 中 作为一个关键词,用来解释 Mysql 是如何执行语句,可以连接 select .dele ...

  7. HBase之行信息简析

    这一节我们简单介绍一下HBase的行信息.文章前半部分会对照源码介绍,后面会有我自己画的图,大家如果对这些信息已经比较了解了,跳过源码对照部分看后面的图,加深一下印象. 下面简单分析一下HBase中对 ...

  8. 【Spark篇】---Spark中Shuffle机制,SparkShuffle和SortShuffle

    一.前述 Spark中Shuffle的机制可以分为HashShuffle,SortShuffle. SparkShuffle概念 reduceByKey会将上一个RDD中的每一个key对应的所有val ...

  9. Python内置函数(32)——input

    英文文档: input([prompt]) If the prompt argument is present, it is written to standard output without a ...

  10. docker for mac 创建私有仓库

    拉取镜像 docker pull registry 运行registry run -d -p : -v /Users/huangenai/docker/registry:/var/lib/regist ...