1、添加dotnet产品Feed

  1. sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc
  2. sudo sh -c 'echo -e "[packages-microsoft-com-prod]\nname=packages-microsoft-com-prod \nbaseurl=https://packages.microsoft.com/yumrepos/microsoft-rhel7.3-prod\nenabled=1\ngpgcheck=1\ngpgkey=https://packages.microsoft.com/keys/microsoft.asc" > /etc/yum.repos.d/dotnetdev.repo'

2、安装.NET Core SDK 2.0

  1. sudo yum update
  2. sudo yum install libunwind libicu
  3. sudo yum install dotnet-sdk-2.0.0

3、查看安装状态

  1. dotnet --info

4、新建一个console项目,运行

  1. dotnet new console -o myApp
  2. cd myApp
  3. dotnet run

5、新建一个mvc项目、发布 、开机运行

新建:

  1. cd ..
    dotnet new mvc -o mymvc

修改Startup.cs 文件,nginx反向代理使用。

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Threading.Tasks;
  5. using Microsoft.AspNetCore.Builder;
  6. using Microsoft.AspNetCore.Hosting;
  7. using Microsoft.Extensions.Configuration;
  8. using Microsoft.Extensions.DependencyInjection;
  9.  
  10. //添加引用
  11. using Microsoft.AspNetCore.HttpOverrides;
  12. namespace mymvc
  13. {
  14. public class Startup
  15. {
  16. public Startup(IConfiguration configuration)
  17. {
  18. Configuration = configuration;
  19.  
  20. }
  21.  
  22. public IConfiguration Configuration { get; }
  23.  
  24. // This method gets called by the runtime. Use this method to add services to the container.
  25. public void ConfigureServices(IServiceCollection services)
  26. {
  27. services.AddMvc();
  28. }
  29.  
  30. // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
  31. public void Configure(IApplicationBuilder app, IHostingEnvironment env)
  32. {
  33. if (env.IsDevelopment())
  34. {
  35. app.UseDeveloperExceptionPage();
  36. }
  37. else
  38. {
  39. app.UseExceptionHandler("/Home/Error");
  40. }
  41. app.UseStaticFiles();
  42. app.UseMvc(routes =>
  43. {
  44. routes.MapRoute(
  45. name: "default",
  46. template: "{controller=Home}/{action=Index}/{id?}");
  47. });
  48. //添加下面的代码
  49. app.UseForwardedHeaders(new ForwardedHeadersOptions
  50. {
  51. ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto
  52. });
  53. app.UseAuthentication();
  54. }
  55. }
  56. }

发布

  1. cd mymvc
  2. dotnet publish -c Release

运行

  1. cd bin/Release/netcoreapp2.0/publish
  2. dotnet mymvc.dll

开机运行(/root 为实际文件目录)

  1. vim /etc/systemd/system/kestrel-mymvc.service
  2.  
  3. -- 内容如下:
  4. [Unit]
  5. Description=Example .NET Web MVC Application running on Centos7
  6.  
  7. [Service]
  8. WorkingDirectory=/root/mymvc
  9. ExecStart=/usr/bin/dotnet /root/mymvc/bin/Release/netcoreapp2.0/publish/mymvc.dll
  10. Restart=always
  11. RestartSec= # Restart service after seconds if dotnet service crashes
  12. SyslogIdentifier=dotnet-example
  13. User=root
  14. Environment=ASPNETCORE_ENVIRONMENT=Production
  15.  
  16. [Install]
  17. WantedBy=multi-user.target
  1. --启动
  2. systemctl enable kestrel-mymvc.service
  3. systemctl start kestrel-mymvc.service
  4. systemctl status kestrel-mymvc.service
  5.  
  6. --修改,重启
  7. systemctl daemon-reload
  8. systemctl restart kestrel-mymvc.service

Linux-RedHat7.2 安装.net core2.0的更多相关文章

  1. redhat7.4安装vertica-9.1.0教程

    资源: 官网地址安装包1: https://my.vertica.com/dashboard/ 官网地址安装包2: http://www.verticachina.com/?cat=73 我的vert ...

  2. 【Linux】Ubuntu安装Mysql 8.0

    1.下载Mysql的安装配置,http://dev.mysql.com/downloads/repo/apt/ 2.执行配置配置文件 sudo dpkg -i mysql-apt-config_0.* ...

  3. ubuntu linux 1604 编译安装tesseract-ocr 4.0

    主要参考官方的编译,梳理一下整个流程 Linux The build instructions for Linux also apply to other UNIX like operating sy ...

  4. Linux CentOS6.5安装Nginx1.8.0

    一. 安装nginx 1. 准备1.8.0安装包 nginx-1.8.0.tar.gz 2. 安装第三方依赖 yum install gcc-c++ yum install -y pcre pcre- ...

  5. 0级搭建类002-Oracle Linux 8.x安装(OEL 8.0) 公开

    项目文档引子系列是根据项目原型,制作的测试实验文档,目的是为了提升项目过程中的实际动手能力,打造精品文档AskScuti. 项目文档引子系列目前不对外发布,仅作为博客记录.如学员在实际工作过程中需提前 ...

  6. [Linux] 非root安装GCC9.1.0

    说明 一般Linux系统自带或公共的GCC版本都很低,如目前我们的服务器版本的GCC还停留在gcc-4.9.3,而官网已到达9.2版本(下载http://ftp.gnu.org/gnu/gcc/) , ...

  7. Linux CentOS 7 安装mongoDB(4.0.6)

    在官网下载安装包: https://www.mongodb.com/download-center/community 或者通过wget下载 wget https://fastdl.mongodb.o ...

  8. linux源码安装php7.2.0

    1. 源码包下载地址 2. 解压php压缩包 tar –zxvf php-7.2.0.tar.gz 3. 进入解压后的 cd php7.2.0 4.安装php需要的扩展 yum install lib ...

  9. Linux CentOS上安装 MySQL 8.0.16

    前言: 因为我需要在我新安装的Linux CentOS系统服务器中安装和配置MySQL服务器,然而对于我们这种Linux使用小白而言在Linux系统中下载,解压,配置MySQL等一系列的操作还是有些耗 ...

随机推荐

  1. struts2添加需要的jar包

    转自:https://blog.csdn.net/fance611261/article/details/6790737 以前总是在myeclipse中添加jar包的,由于现在转向了eclipse,原 ...

  2. 关于spring boot打出的jar包在Linux中运行

    众所周知, spring boot打出的jar包可以通过 "java -jar xxx.jar"的方式来运行 但是在Linux中, 通过这个命令运行的话会占用该窗口, 当我们 Ct ...

  3. 装饰器模式(Decorator) C++

    装饰器模式是比较常用的一种设计模式,Python中就内置了对于装饰器的支持. 具体来说,装饰器模式是用来给对象增加某些特性或者对被装饰对象进行某些修改. 如上图所示,需要被装饰的对象在最上方,它自身可 ...

  4. hdoj5003【wa水】

    蜜汁wa,蜜汁wa,少了个\n------ #include<bits/stdc++.h> using namespace std; typedef long long LL; typed ...

  5. 了解Web Uploader

    1.简介WebUploader是由Baidu WebFE(FEX)团队开发的一个简单的以HTML5为主,FLASH为辅的现代文件上传组件.在现代的浏览器里面能充分发挥HTML5的优势,同时又不摒弃主流 ...

  6. bzoj 4871: [Shoi2017]摧毁“树状图”【树形dp】

    做不来--参考https://www.cnblogs.com/ezyzy/p/6784872.html #include<iostream> #include<cstdio> ...

  7. vue父组件调用子组件方法

    父组件: 代码 <sampleapplylinemodel ref="sampleapplylinemodel" @reLoad="_fetchRecords&qu ...

  8. iOS UITableView reloadData 刷新结束后执行后续操作

    如果在reloadData后需要立即获取tableview的cell.高度,或者需要滚动tableview. 如果直接在reloadData后执行代码是有可能出问题的,比如indexPath为nil等 ...

  9. Centos6.8 配置 Tomcat

    1.安装Tomcat,安装之前必须先安装Java,先安装java 下载地址:http://www.oracle.com/technetwork/java/javase/downloads/index. ...

  10. 数据库sql 使用 lag 和OVER 函数和 like 使用 小技巧

    1. sample 1: Lag()就是取当前顺序的上一行记录.结合over就是分组统计数据的.Lag()函数,就是去上N行的字段的数据. SQL> select * from x; A---- ...