一、Centos7下.Net Core 环境安装:

链接:https://www.microsoft.com/net/core#linuxcentos

按照步骤来:

yum install libunwind libicu
curl -sSL -o dotnet.tar.gz https://go.microsoft.com/fwlink/?LinkID=835019
mkdir -p /opt/dotnet && sudo tar zxf dotnet.tar.gz -C /opt/dotnet
ln -s /opt/dotnet/dotnet /usr/local/bin

就这样,.Net Core环境搭建好了,可以使用dotnet --version查看版本号。

可以把我们的.Net Core程序上传到服务器上,使用命令dotnet xxx.dll运行我们的程序。

二、使用Nginx代理转发

参考资料:https://www.digitalocean.com/community/tutorials/how-to-install-nginx-on-centos-7

1.添加CentOS 7 EPEL存储库:

yum install epel-release

2.Nginx存储库安装在您的服务器上,使用以下yum命令安装Nginx:

yum install nginx

3.启用Nginx,设置开机启动

systemctl start nginx #启用Nginx 

systemctl enable nginx #设置开机启动

4.使用firewall或iptables开发80端口,这样就可以使用http://ip地址 访问,看到如下这个界面就说明Nginx服务开启成功!

5.配置转发规则:

修改配置,监听5000端口:路径为:/etc/nginx/nginx.conf,修改如下:

location/{
# 传递真实IP到后端
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://localhost:5000;
}

三、使用Supervisor守护进程

参考链接:http://www.cnblogs.com/savorboard/p/dotnetcore-supervisor.html

3.1安装Supervisor :

yum install python-setuptools

easy_install supervisor 

mkdir /ect/supervisor #创建目录

echo_supervisord_conf > /etc/supervisor/supervisord.conf  #配置文件

3.2配置Supervisor:

在/etc/supervisor/confg.d/(如果没有,就创建目录)下新建个名字为CManage.conf(名字xxx.conf就行)配置,

内容如下:

[program:CManage]
command=dotnet CManage.dll #要执行的命令
directory=/home/wwwroot #命令执行的目录
environment=ASPNETCORE__ENVIRONMENT=Production #环境变量
user=www-data #进程执行的用户身份
stopsignal=INT
autostart=true #是否自动启动
autorestart=true #是否自动重启
startsecs= #自动重启间隔
stderr_logfile=/var/log/CManage.err.log #标准错误日志
stdout_logfile=/var/log/CManage.out.log #标准输出日志

3.3配置完了之后,需要修改/etc/supervisor/supervisord.conf文件:

最底部的[include]修改为:

[include]
files = /etc/supervisor/conf.d/*.conf 

然后需要把supervisord重新加载:

supervisord -c /etc/supervisor/supervisord.conf

3.4打开服务:

ps -ef | grep CManage

3.5Supervisor 的常用命令:

supervisorctl shutdown #关闭所有任务

supervisorctl stop|start program_name  开启或者停止任务

supervisorctl status #查看所有任务状态

3.6这时候Supervisor相关配置完了,设置开机启动,这样就不用每次重启服务器还需要启用守护进程了。

在/usr/lib/systemd/system/目录新建个supervisord.service文件,内容如下:

  # dservice for systemd (CentOS 7.0+)
  # by ET-CS (https://github.com/ET-CS)
  [Unit]
  Description=Supervisor daemon   [Service]
  Type=forking
  ExecStart=/usr/bin/supervisord -c /etc/supervisor/supervisord.conf
  ExecStop=/usr/bin/supervisorctl shutdown
  ExecReload=/usr/bin/supervisorctl reload
  KillMode=process
  Restart=on-failure
  RestartSec=42s   [Install]
  WantedBy=multi-user.target

设置开机启动:

systemctl enable supervisord  设置为开机启动

四、Supervisor UI 管理台

Supervisor 默认给我们提供了一个图形界面来供我们管理进程和任务,我们可以修改配置文件/etc/supervisor/supervisord.conf,添加inet_http_server 节点:

然后就可以通过界面来查看运行的进程了:

Linux学习之十--.Net Core环境搭建以及Nginx的搭建的更多相关文章

  1. 学习笔记:CentOS7学习之十五: RAID磁盘阵列的原理与搭建

    目录 学习笔记:CentOS7学习之十五: RAID磁盘阵列的原理与搭建 14.1 RAID概念 14.1.1 RAID几种常见的类型 14.1.2 RAID-0工作原理 14.1.3 RAID-1工 ...

  2. Linux学习之十四、管线命令

    Linux学习之十四.管线命令 地址:http://vbird.dic.ksu.edu.tw/linux_basic/0320bash_6.php

  3. CentOS 环境下基于 Nginx uwsgi 搭建 Django 站点

    因为我的个人网站 restran.net 已经启用,博客园的内容已经不再更新.请访问我的个人网站获取这篇文章的最新内容,CentOS 环境下基于 Nginx uwsgi 搭建 Django 站点 以下 ...

  4. Linux学习--第十天--bash脚本、用户自定义变量、环境变量、位置参数变量、预定义变量、标准输入输出、wc、history、dd、PS1

    shell简介 分为两种c shell 和b shell b shell:sh.ksh.Bash.psh.zsh: (Bash和sh兼容,linux基本shell是Bash) c shell:csh. ...

  5. Linux学习之十五、基础正规表示法\延伸正规表示法

    原文地址: http://vbird.dic.ksu.edu.tw/linux_basic/0330regularex_2.php 基础正规表示法 既然正规表示法是处理字串的一种表示方式,那么对字节排 ...

  6. linux学习(十)Shell中的控制语句

    目录 1. 条件测试语句 1.1 test语句 1.2[]语句 1.3文件测试 1.4字符串测试 1.5数值测试 1.5逻辑操作符 @(Shell中的控制语句) 1. 条件测试语句 测试语句十Shel ...

  7. linux学习(十)find命令、Linux文件后缀名、Linux和windows文件互传

    一.和find相关的几个搜索命令,了解即可. 1.1 which [root@iZ25lzba47vZ ~]# which ls alias ls='ls --color=auto' /usr/bin ...

  8. linux学习第十九天 (Linux就该这么学) 结课了

    今天最后一天课程了,结课了,还有点舍不得那,在些也祝 李老师 事业蒸蒸日上,超来超好, 今天内容是部署了 LNMP 部署动态网站环境(linux  +nginx+mysql+php) 安装文件挺别多, ...

  9. Linux学习5-CentOS安装Python3.6环境和pip3

    前言 centos7 自带有 python,但是却是 python2 版本的 python,如果你想安装个python3怎么办呢? 如果直接删除python2的话,可能会引起其他的问题,因为有些东西是 ...

随机推荐

  1. UNITY实现FLASH中的setTimeout

    setTimeout是一个很方便的DELAY处理方法 if (this.startUpDelay > 0){            StartCoroutine(DelayedStart()); ...

  2. CRC32

    CRC32生成多项式:X32+X26+X23+X22+X16+X12+X11+X10+X8+X7+X5+X4+X2+X+1 对应的16进制表示为:0x4C11DB7 下面贴CRC32查表法生成代码: ...

  3. [LeetCode] Trapping Rain Water 收集雨水

    Given n non-negative integers representing an elevation map where the width of each bar is 1, comput ...

  4. Spark Rdd coalesce()方法和repartition()方法

    在Spark的Rdd中,Rdd是分区的. 有时候需要重新设置Rdd的分区数量,比如Rdd的分区中,Rdd分区比较多,但是每个Rdd的数据量比较小,需要设置一个比较合理的分区.或者需要把Rdd的分区数量 ...

  5. C语言共用体、大小端、枚举

    1.共用体和结构体的相同和不同 (1)相同点就是操作语法几乎相同.(2)不同点是本质上的不同.struct是多个独立元素(内存空间)打包在一起:union是一个元素(内存空间)的多种不同解析方式. # ...

  6. Babel:JavaScript编译器

    一.介绍: Babel是一个Javascript编译器,可以将ES6语法转换成ES5. 这意味着,你可以现在就用ES6编写程序,而不用担心现有环境是否支持.下面是一个例子: //转码前: input. ...

  7. Maven的pom报maven-surefire-plugin:pom:2.12.4

    新建Maven项目,报错: Failure to transfer org.apache.maven.plugins:maven-surefire-plugin:pom:2.12.4 from htt ...

  8. Centos 7 使用jenkins 打包android项目

      1.配置java环境   在sun官网下载,解压后放入/usr/java下,并配置环境变量如 vi /etc/profile 在最底部加入如下配置(注:添加环境变量,都是在文件最底部添加)   J ...

  9. 用hibernate tools生成对应的sql应用代码

    参考资料: eclipse在线配置hibernate tools http://jingyan.baidu.com/article/db55b609959d154ba20a2f5d.html [图]H ...

  10. LVM逻辑卷管理命令

    显示分区信息: [root@localhost /]# fdisk -l PV:物理硬盘格式化为物理卷(PV): [root@localhost /]# pvcreate /dev/sdb /dev/ ...