Linux-RedHat7.2 安装.net core2.0
1、添加dotnet产品Feed
sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc
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
sudo yum update
sudo yum install libunwind libicu
sudo yum install dotnet-sdk-2.0.0
3、查看安装状态
dotnet --info
4、新建一个console项目,运行
dotnet new console -o myApp
cd myApp
dotnet run

5、新建一个mvc项目、发布 、开机运行
新建:
cd ..
dotnet new mvc -o mymvc
修改Startup.cs 文件,nginx反向代理使用。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection; //添加引用
using Microsoft.AspNetCore.HttpOverrides; namespace mymvc
{
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration; } public IConfiguration Configuration { get; } // This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc();
} // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseExceptionHandler("/Home/Error");
}
app.UseStaticFiles();
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
//添加下面的代码
app.UseForwardedHeaders(new ForwardedHeadersOptions
{
ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto
});
app.UseAuthentication();
}
}
}
发布
cd mymvc
dotnet publish -c Release
运行
cd bin/Release/netcoreapp2.0/publish
dotnet mymvc.dll
开机运行(/root 为实际文件目录)
vim /etc/systemd/system/kestrel-mymvc.service -- 内容如下:
[Unit]
Description=Example .NET Web MVC Application running on Centos7 [Service]
WorkingDirectory=/root/mymvc
ExecStart=/usr/bin/dotnet /root/mymvc/bin/Release/netcoreapp2.0/publish/mymvc.dll
Restart=always
RestartSec= # Restart service after seconds if dotnet service crashes
SyslogIdentifier=dotnet-example
User=root
Environment=ASPNETCORE_ENVIRONMENT=Production [Install]
WantedBy=multi-user.target
--启动
systemctl enable kestrel-mymvc.service
systemctl start kestrel-mymvc.service
systemctl status kestrel-mymvc.service --修改,重启
systemctl daemon-reload
systemctl restart kestrel-mymvc.service

Linux-RedHat7.2 安装.net core2.0的更多相关文章
- redhat7.4安装vertica-9.1.0教程
资源: 官网地址安装包1: https://my.vertica.com/dashboard/ 官网地址安装包2: http://www.verticachina.com/?cat=73 我的vert ...
- 【Linux】Ubuntu安装Mysql 8.0
1.下载Mysql的安装配置,http://dev.mysql.com/downloads/repo/apt/ 2.执行配置配置文件 sudo dpkg -i mysql-apt-config_0.* ...
- ubuntu linux 1604 编译安装tesseract-ocr 4.0
主要参考官方的编译,梳理一下整个流程 Linux The build instructions for Linux also apply to other UNIX like operating sy ...
- 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- ...
- 0级搭建类002-Oracle Linux 8.x安装(OEL 8.0) 公开
项目文档引子系列是根据项目原型,制作的测试实验文档,目的是为了提升项目过程中的实际动手能力,打造精品文档AskScuti. 项目文档引子系列目前不对外发布,仅作为博客记录.如学员在实际工作过程中需提前 ...
- [Linux] 非root安装GCC9.1.0
说明 一般Linux系统自带或公共的GCC版本都很低,如目前我们的服务器版本的GCC还停留在gcc-4.9.3,而官网已到达9.2版本(下载http://ftp.gnu.org/gnu/gcc/) , ...
- Linux CentOS 7 安装mongoDB(4.0.6)
在官网下载安装包: https://www.mongodb.com/download-center/community 或者通过wget下载 wget https://fastdl.mongodb.o ...
- 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 ...
- Linux CentOS上安装 MySQL 8.0.16
前言: 因为我需要在我新安装的Linux CentOS系统服务器中安装和配置MySQL服务器,然而对于我们这种Linux使用小白而言在Linux系统中下载,解压,配置MySQL等一系列的操作还是有些耗 ...
随机推荐
- Win32控制台程序和Win32应用程序
刚接触Windows那一套,大多数概念都还没建立起来,整理了一下网上对“Win32控制台程序”的理解,谢谢各位网友了. win32控制台项目指在32位Windows命令提示符(即所谓的dos)环境下运 ...
- MFC类别概述
MFC 类别主要可分为下列数大群组: ■ General Purpose classes - 提供字符串类别.数据处理类别(如数组与串行),异 常情况处理类别.文件类别...等等. ■ Windows ...
- 875. Koko Eating Bananas
Koko loves to eat bananas. There are N piles of bananas, the i-th pile has piles[i] bananas. The g ...
- 详解基于linux环境MySQL搭建与卸载
本篇文章将从实际操作的层面,讲解基于linux环境的mysql的搭建和卸载. 1 搭建mysql 1.1 官网下载mysql压缩包 下载压缩包时,可以先把安装包下载到本地,再上传到服务器,也可以在 ...
- the little schemer 笔记(7)
第七章 Friends and Relations 这是一个set集合吗 (apple peaches apple plum) 不是,apple出现了不止一次 (set? lat) 是真还是假,其中l ...
- C语言-------指针函数与函数指针的区别
一. 在学习arm过程中发现这“指针函数”与“函数指针”容易搞错,所以今天,我自己想一次把它搞清楚,找了一些资料,首先它们之间的定义: 1.指针函数是指带指针的函数,即本质是一个函数.函数返回类型是某 ...
- oracle 查看未关闭连接
查看连接状态.问题电脑等信息: select sid,serial#,username,program,machine,status from v$session; 2.查看sql; select ...
- 日历 php
<?php $year=@$_GET['year']; //获得地址栏的年份 $month=@$_GET['month']; //获得地址栏的月份 if(empty($year)) $year= ...
- AJPFX:不用递归巧妙求出1000的阶乘所有零和尾部零的个数
package com.jonkey.test; import java.math.BigInteger; public class Test6 { /*** @param args* 需求:求出1 ...
- 【经验总结】关于使用某些第三方插件库元素设置display:none后重新show不显示的问题;(display、opacity、宽高0的使用场景)
display:none 直接取消元素所占用的位置(但是元素还是存在的),后面元素看他就相当于不存在了: opacity:0 隐藏,但是其依旧占用位置: height.width:0 和displa ...