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等一系列的操作还是有些耗 ...
随机推荐
- struts2添加需要的jar包
转自:https://blog.csdn.net/fance611261/article/details/6790737 以前总是在myeclipse中添加jar包的,由于现在转向了eclipse,原 ...
- 关于spring boot打出的jar包在Linux中运行
众所周知, spring boot打出的jar包可以通过 "java -jar xxx.jar"的方式来运行 但是在Linux中, 通过这个命令运行的话会占用该窗口, 当我们 Ct ...
- 装饰器模式(Decorator) C++
装饰器模式是比较常用的一种设计模式,Python中就内置了对于装饰器的支持. 具体来说,装饰器模式是用来给对象增加某些特性或者对被装饰对象进行某些修改. 如上图所示,需要被装饰的对象在最上方,它自身可 ...
- hdoj5003【wa水】
蜜汁wa,蜜汁wa,少了个\n------ #include<bits/stdc++.h> using namespace std; typedef long long LL; typed ...
- 了解Web Uploader
1.简介WebUploader是由Baidu WebFE(FEX)团队开发的一个简单的以HTML5为主,FLASH为辅的现代文件上传组件.在现代的浏览器里面能充分发挥HTML5的优势,同时又不摒弃主流 ...
- bzoj 4871: [Shoi2017]摧毁“树状图”【树形dp】
做不来--参考https://www.cnblogs.com/ezyzy/p/6784872.html #include<iostream> #include<cstdio> ...
- vue父组件调用子组件方法
父组件: 代码 <sampleapplylinemodel ref="sampleapplylinemodel" @reLoad="_fetchRecords&qu ...
- iOS UITableView reloadData 刷新结束后执行后续操作
如果在reloadData后需要立即获取tableview的cell.高度,或者需要滚动tableview. 如果直接在reloadData后执行代码是有可能出问题的,比如indexPath为nil等 ...
- Centos6.8 配置 Tomcat
1.安装Tomcat,安装之前必须先安装Java,先安装java 下载地址:http://www.oracle.com/technetwork/java/javase/downloads/index. ...
- 数据库sql 使用 lag 和OVER 函数和 like 使用 小技巧
1. sample 1: Lag()就是取当前顺序的上一行记录.结合over就是分组统计数据的.Lag()函数,就是去上N行的字段的数据. SQL> select * from x; A---- ...