.net core系列之《将.net core应用部署到Ubuntu》

1、首先准备一个演示项目。

2、然后将这个项目用FileZilla工具上传到Ubuntu中。

3、进入目标文件,接下来有两种方法来部署项目

  a、用dotnet run命令

root@hhz-virtual-machine:~# cd /source
root@hhz-virtual-machine:/source# ls
Commom  ReleaseSample  ReleaseSample.sln
root@hhz-virtual-machine:/source# cd ReleaseSample
root@hhz-virtual-machine:/source/ReleaseSample# ls
appsettings.Development.json  bin  ops.Development.json  Program.cs  ReleaseSample.csproj
appsettings.Production.json   obj  ops.Production.json   Properties  ReleaseSample.csproj.user
root@hhz-virtual-machine:/source/ReleaseSample# dotnet run -c Release
服务成功开启!
2018/10/8 下午3:37:54 :业务逻辑处理中
2018/10/8 下午3:37:55 :业务逻辑处理中
2018/10/8 下午3:37:56 :业务逻辑处理中
2018/10/8 下午3:37:57 :业务逻辑处理中
2018/10/8 下午3:37:58 :业务逻辑处理中

  b、用dotnet publish命令(微软推荐)

root@hhz-virtual-machine:/source/ReleaseSample# dotnet publish -o /data/output -c Release
Microsoft (R) Build Engine version 15.8.169+g1ccb72aefa for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

  Restore completed in 40.19 ms for /source/ReleaseSample/ReleaseSample.csproj.
  Restore completed in 40.19 ms for /source/Commom/Commom.csproj.
  Commom -> /source/Commom/bin/Release/netstandard2.0/Commom.dll
  ReleaseSample -> /source/ReleaseSample/bin/Release/netcoreapp2.1/ReleaseSample.dll
  ReleaseSample -> /data/output/
hhz@hhz-virtual-machine:/data/output$ ls
Commom.dll                                             Microsoft.Extensions.FileProviders.Abstractions.dll  ReleaseSample.dll
Commom.pdb                                             Microsoft.Extensions.FileProviders.Physical.dll      ReleaseSample.pdb
Microsoft.Extensions.Configuration.Abstractions.dll    Microsoft.Extensions.FileSystemGlobbing.dll          ReleaseSample.runtimeconfig.json
Microsoft.Extensions.Configuration.dll                 Microsoft.Extensions.Primitives.dll                  System.Runtime.CompilerServices.Unsafe.dll
Microsoft.Extensions.Configuration.FileExtensions.dll  Newtonsoft.Json.dll
Microsoft.Extensions.Configuration.Json.dll            ReleaseSample.deps.json
hhz@hhz-virtual-machine:/data/output$ dotnet ReleaseSample.dll
服务成功开启!
2018/10/8 下午3:43:44 :业务逻辑处理中
2018/10/8 下午3:43:45 :业务逻辑处理中
2018/10/8 下午3:43:46 :业务逻辑处理中
2018/10/8 下午3:43:47 :业务逻辑处理中

4、将部署的项目设置为后台进程

  a、用nohup dotnet xxx.dll &命令

root@hhz-virtual-machine:/data/output# nohup dotnet ReleaseSample.dll &
[1] 13334
root@hhz-virtual-machine:/data/output# nohup: 忽略输入并把输出追加到'nohup.out'

root@hhz-virtual-machine:/data/output# ls
Commom.dll                                             Microsoft.Extensions.Configuration.Json.dll          Newtonsoft.Json.dll      ReleaseSample.runtimeconfig.json
Commom.pdb                                             Microsoft.Extensions.FileProviders.Abstractions.dll  nohup.out                System.Runtime.CompilerServices.Unsafe.dll
Microsoft.Extensions.Configuration.Abstractions.dll    Microsoft.Extensions.FileProviders.Physical.dll      ReleaseSample.deps.json
Microsoft.Extensions.Configuration.dll                 Microsoft.Extensions.FileSystemGlobbing.dll          ReleaseSample.dll
Microsoft.Extensions.Configuration.FileExtensions.dll  Microsoft.Extensions.Primitives.dll                  ReleaseSample.pdb

由上面的目录我们可以看出,多出了一个nohup.out文件,这个文件是用来放输入信息的:

root@hhz-virtual-machine:/data/output# tail nohup.out
2018/10/8 下午3:52:50 :业务逻辑处理中
2018/10/8 下午3:52:51 :业务逻辑处理中
2018/10/8 下午3:52:52 :业务逻辑处理中
2018/10/8 下午3:52:53 :业务逻辑处理中
2018/10/8 下午3:52:54 :业务逻辑处理中
2018/10/8 下午3:52:55 :业务逻辑处理中
2018/10/8 下午3:52:56 :业务逻辑处理中
2018/10/8 下午3:52:57 :业务逻辑处理中
2018/10/8 下午3:52:58 :业务逻辑处理中
2018/10/8 下午3:52:59 :业务逻辑处理中
root@hhz-virtual-machine:/data/output# tail nohup.out
2018/10/8 下午3:52:52 :业务逻辑处理中
2018/10/8 下午3:52:53 :业务逻辑处理中
2018/10/8 下午3:52:54 :业务逻辑处理中
2018/10/8 下午3:52:55 :业务逻辑处理中
2018/10/8 下午3:52:56 :业务逻辑处理中
2018/10/8 下午3:52:57 :业务逻辑处理中
2018/10/8 下午3:52:58 :业务逻辑处理中
2018/10/8 下午3:52:59 :业务逻辑处理中
2018/10/8 下午3:53:00 :业务逻辑处理中
2018/10/8 下午3:53:01 :业务逻辑处理中

转载于:https://www.cnblogs.com/hhzblogs/p/9754892.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值