用到的软件如下

xshell,xftp,vs2017.3,centos 7.3 64位

安装环境

aliyun centos 7.3 64位

安装.net core 2.0 依赖的组件

yum install deltarpm epel-release unzip libunwind gettext libcurl-devel openssl-devel zlib libicu-devel

安装.net core 2.0

sudo dnf install libunwind libicucurl -sSL -o dotnet.tar.gz https://aka.ms/dotnet-sdk-2.0.0-linux-x64sudo mkdir -p /opt/dotnet && sudo tar zxf dotnet.tar.gz -C /opt/dotnetsudo ln -s /opt/dotnet/dotnet /usr/local/bindotnet --help

在命令 dotnet --help 看到下面信息就安装.net core 2.0成功了

[root@iZ6r8lfyydxll0Z ~]# dotnet --help.NET Command Line Tools (2.0.0)Usage: dotnet [runtime-options] [path-to-application]Usage: dotnet [sdk-options] [command] [arguments] [command-options] path-to-application:  The path to an application .dll file to execute. 

使用VS2017.3 新建一个.net core 2.0 的测试代码

使用xftp 把生成好的程序 (webcore/webcore/bin/Debug/netcoreapp2.0/publish下的文件)上传到 /home/test 目录下

安装配置nginx

yum install nginx

配置nginx.conf

server {     listen 80;    server_name  test.fun5.cn;     location / {        proxy_pass http://localhost:5000;        proxy_http_version 1.1;        proxy_set_header Upgrade $http_upgrade;        proxy_set_header Connection keep-alive;        proxy_set_header Host $host;        proxy_cache_bypass $http_upgrade;    }     error_page 404 /404.html;        location = /40x.html {    }     error_page 500 502 503 504 /50x.html;        location = /50x.html {    }}

配置守护进程安装Supervisor

yum install Supervisor

Supervisor配置文件,创建一个ini 配置文件 webcore.ini

[program:webcore]command=dotnet webcore.dlldirectory=/home/testenvironment=ASPNETCORE__ENVIRONMENT=Productionuser=rootstopsignal=INTautostart=trueautorestart=truestartsecs=3stderr_logfile=/var/log/webcore.err.log stdout_logfile=/var/log/webcore.out.log

创建好之后,使用 xftp 上次到 /etc/supervisord.d 目录下

最后启动

supervisord -c /etc/supervisord.conf

执行 nginx -s reload

访问 nginx 绑定的域名可以看到网站可以跑起来了

到这里基本上就配置好了 nginx + linux + .net core 2.0


如果想要supervisord开机自启动

编辑启动文件

vi /etc/rc.local

在新行添加要执行的命令

supervisord  -c /etc/supervisord.conf

常用命令

查看所有action

 
supervisorctl help

控制所有进程

supervisorctl start allsupervisorctl stop allsupervisorctl restart all

控制目标进程

supervisorctl stop shadowsockssupervisorctl start shadowsockssupervisorctl restart shadowsocks

 

收藏 打印