一、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. sql

    http://www.cnblogs.com/ASPNET2008/archive/2012/06/30/2570737.html

  2. 安全测试 - 抓包工具BurpSuite

    Brup SuiteBurpSuite是用于攻击web应用程序的集成平台.它包含了许多工具,并为这些工具设计了许多接口,以促进加快攻击应用程序的过程.所有的工具都共享一个能处理并显示HTTP消息,持久 ...

  3. C++类继承关系视图的自动生成

    原创文章,转载请注明出处. 工欲善其事,必先利其器.阅读大型C++工程项目,如果有一些自动化的分析工具支持,学习的效率将大大提升.在前文中介绍了Source Insight在Linux下的安装方法,本 ...

  4. [LeetCode] Find Median from Data Stream 找出数据流的中位数

    Median is the middle value in an ordered integer list. If the size of the list is even, there is no ...

  5. [LeetCode] Longest Common Prefix 最长共同前缀

    Write a function to find the longest common prefix string amongst an array of strings. 这道题让我们求一系列字符串 ...

  6. iOS开发小技巧 -- tableView-section圆角边框解决方案

    [iOS开发]tableView-section圆角边框解决方案 tableView圆角边框解决方案 iOS 7之前,图下圆角边框很容易设置 iOS 7之后,tableviewcell的风格不再是圆角 ...

  7. 【.NET】Cookie操作类

    public static class CookiesHelper { /// <summary> /// Cookies赋值 /// </summary> /// <p ...

  8. JavaScript零基础学习系列五

    定时器 1.定时器:设定时间,在指定的时间之后执行函数或者是程序   a.反复性定时器:var dingshiqi=Window.setInterval("函数名()",时间n[毫 ...

  9. 在windows上部署使用Redis

    参考地址: http://keenwon.com/1275.html

  10. Scala - 隐式转换和隐式参数

    隐士转换是Scala提供的一种语法糖 Implicit definitions are those that the compiler is allowed to insert into a prog ...