.net core api 部署 Linux Debian 11

1、安装 .net core 3.1 

安装步骤参考微软文档

https://docs.microsoft.com/zh-cn/dotnet/core/install/linux-debian

第一步执行:

wget https://packages.microsoft.com/config/debian/11/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
rm packages-microsoft-prod.deb

第二步执行(我这采用的是.net core 3.1版本):

sudo apt-get update; \
sudo apt-get install -y apt-transport-https && \
sudo apt-get update && \
sudo apt-get install -y dotnet-sdk-3.1

 

2、打包发布 net core 到liunx系统 我这采用 国产 FinalShell 工具连接

直接上传到 home 文件夹用户文档,其他文件要提升权限才可以

3、启动

启动命令指定 端口:5000,前面用“*” 可以同时监听本地地址和ip4地址

dotnet FAST.API.Core.dll --urls http://*:5000

 

这边我报了一个错,

日志时间:2021-11-18 20:49:41.822 未知异常: System.TypeInitializationException: The type initializer for 'System.DrawingCore.GDIPlus' threw an exception.
---> System.DllNotFoundException: Unable to load shared library 'gdiplus' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: libgdiplus: cannot open shared object file: No such file or directory
at System.DrawingCore.GDIPlus.GdiplusStartup(UInt64& token, GdiplusStartupInput& input, GdiplusStartupOutput& output)
at System.DrawingCore.GDIPlus..cctor()
--- End of inner exception stack trace ---
at System.DrawingCore.GDIPlus.GdipCreateBitmapFromScan0(Int32 width, Int32 height, Int32 stride, PixelFormat format, IntPtr scan0, IntPtr& bmp)
at System.DrawingCore.Bitmap..ctor(Int32 width, Int32 height, PixelFormat format)
at System.DrawingCore.Bitmap..ctor(Int32 width, Int32 height)
at FAST.API.Utils.VerificationCode.YZM1.Create(String& code, Int32 numbers)
at FAST.API.Core.Controllers.YZMController.ValidateCode1() in D:\GitSourceCode\tgyth3\SourceCode\Declare\TYB\FAST_API\FAST.API.Core\Controllers\YZMController.cs:line 26
at lambda_method(Closure , Object , Object[] )
at Microsoft.Extensions.Internal.ObjectMethodExecutor.Execute(Object target, Object[] parameters)
at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.SyncActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeActionMethodAsync()
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeNextActionFilterAsync()
--- End of stack trace from previous location where exception was thrown ---
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()
--- End of stack trace from previous location where exception was thrown ---
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeFilterPipelineAsync>g__Awaited|19_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
at FAST.API.Core.Middlewares.ExceptionMiddleWare.Invoke(HttpContext context) in D:\GitSourceCode\tgyth3\SourceCode\Declare\TYB\FAST_API\FAST.API.Core\Middlewares\ExceptionMiddleWare.cs:line 25

 

需要安装包

执行命令:

sudo apt-get install libgdiplus 

在重启API

dotnet FAST.API.Core.dll --urls http://*:5000

 

3、开启外网访问

 

iptables -A INPUT -p tcp --dport 5000:6000 -j ACCEPT

我这设置了,没有效果

重启电脑生效了

其他:

查看端口占用:

netstat  -anp  |grep  3306

 

posted @ 2021-11-19 09:16  逍遥子_何  阅读(686)  评论(0编辑  收藏  举报