• .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 :业务逻辑处理中
  • 相关阅读:
    google搜索引擎使用方法
    通过Ajax和SpringBoot交互的示例
    利用html sessionStorge 来保存局部页面在刷新后回显,保留
    JS页面刷新保持数据不丢失
    Firefox浏览器中,input输入框输入的内容在刷新网页后为何还在?
    关于form/input 的autocomplete="off"属性
    Java对日期Date类进行加减运算,年份加减,月份加减
    select标签设置只读的方法(下拉框不可选但可传值)
    用Thymeleaf在前台下拉列表取值
    jsp页面动态展示list-使用<select>和<c:forEach>标签
  • 原文地址:https://www.cnblogs.com/hhzblogs/p/9754892.html
Copyright © 2020-2023  润新知