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]LeetCode215. 数组中的第K个最大元素 | Kth Largest Element in an Array

    Find the kth largest element in an unsorted array. Note that it is the kth largest element in the so ...

  2. [Swift]LeetCode436. 寻找右区间 | Find Right Interval

    Given a set of intervals, for each of the interval i, check if there exists an interval j whose star ...

  3. [Swift]LeetCode547. 朋友圈 | Friend Circles

    There are N students in a class. Some of them are friends, while some are not. Their friendship is t ...

  4. [Swift]LeetCode1001. 网格照明 | Grid Illumination

    On a N x N grid of cells, each cell (x, y) with 0 <= x < N and 0 <= y < N has a lamp. In ...

  5. java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.love5/com.example.love5.Main11Activity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.

    若有 java.lang.RuntimeException和 java.lang.NullPointerException: Attempt to invoke virtual method 'voi ...

  6. SecureCRT 5.2.2版本下载和注册码

    Name: Apollo Interactive Company: Apollo Interactive Serial Number: 03-50-023223License Key: ABMVSR ...

  7. scala打包jar并在Linux下运行

    打开 File -> Project Structure Artifacts -> + -> jar -> From Modules with dependisies... 选 ...

  8. BBS论坛(二十)

    20.1.cms添加轮播图后台逻辑代码完成 (1)apps/models.py from exts import db from datetime import datetime class Bann ...

  9. "无需开发经验" 也能拥有小程序

    本文分享嘉宾:毛帅,又拍图片管家资深开发工程师,主要负责又拍图片管家.图管小程序第三方平台.图管小程序等项目的开发.维护及拓新工作.熟悉 JS / C++ 等语言,有丰富的 NodeJS 开发经验,热 ...

  10. ArrayList循环遍历并删除元素的常见陷阱

    在工作和学习中,经常碰到删除ArrayList里面的某个元素,看似一个很简单的问题,却很容易出bug.不妨把这个问题当做一道面试题目,我想一定能难道不少的人.今天就给大家说一下在ArrayList循环 ...