zoukankan      html  css  js  c++  java
  • .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 :业务逻辑处理中
  • 相关阅读:
    第五周总结
    第四周总结
    第三周总结
    开课博客
    学习进度
    个人作业1-数组
    数组
    第一周考试总结
    团队个人冲刺第六天
    团队个人冲刺第五天
  • 原文地址:https://www.cnblogs.com/hhzblogs/p/9754892.html
Copyright © 2011-2022 走看看