.net core api 部署 Linux Debian 11
<p>1、安装 .net core 3.1 </p><p>安装步骤参考微软文档</p>
<p>https://docs.microsoft.com/zh-cn/dotnet/core/install/linux-debian</p>
<p>第一步执行:</p>
<p>wget https://packages.microsoft.com/config/debian/11/packages-microsoft-prod.deb -O packages-microsoft-prod.deb<br>sudo dpkg -i packages-microsoft-prod.deb<br>rm packages-microsoft-prod.deb</p>
<p>第二步执行(我这采用的是.net core 3.1版本):</p>
<p>sudo apt-get update; \<br>sudo apt-get install -y apt-transport-https && \<br>sudo apt-get update && \<br>sudo apt-get install -y dotnet-sdk-3.1</p>
<p> </p>
<p>2、打包发布 net core 到liunx系统 我这采用 国产 FinalShell 工具连接</p>
<p>直接上传到 home 文件夹用户文档,其他文件要提升权限才可以</p>
<p>3、启动</p>
<p>启动命令指定 端口:5000,前面用“*” 可以同时监听本地地址和ip4地址</p>
<p>dotnet FAST.API.Core.dll --urls http://*:5000</p>
<p> </p>
<p>这边我报了一个错,</p>
<p>日志时间:2021-11-18 20:49:41.822 未知异常: System.TypeInitializationException: The type initializer for 'System.DrawingCore.GDIPlus' threw an exception.<br> ---> 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<br> at System.DrawingCore.GDIPlus.GdiplusStartup(UInt64& token, GdiplusStartupInput& input, GdiplusStartupOutput& output)<br> at System.DrawingCore.GDIPlus..cctor()<br> --- End of inner exception stack trace ---<br> at System.DrawingCore.GDIPlus.GdipCreateBitmapFromScan0(Int32 width, Int32 height, Int32 stride, PixelFormat format, IntPtr scan0, IntPtr& bmp)<br> at System.DrawingCore.Bitmap..ctor(Int32 width, Int32 height, PixelFormat format)<br> at System.DrawingCore.Bitmap..ctor(Int32 width, Int32 height)<br> at FAST.API.Utils.VerificationCode.YZM1.Create(String& code, Int32 numbers)<br> at FAST.API.Core.Controllers.YZMController.ValidateCode1() in D:\GitSourceCode\tgyth3\SourceCode\Declare\TYB\FAST_API\FAST.API.Core\Controllers\YZMController.cs:line 26<br> at lambda_method(Closure , Object , Object[] )<br> at Microsoft.Extensions.Internal.ObjectMethodExecutor.Execute(Object target, Object[] parameters)<br> at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.SyncActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)<br> at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeActionMethodAsync()<br> at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)<br> at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeNextActionFilterAsync()<br>--- End of stack trace from previous location where exception was thrown ---<br> at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)<br> at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)<br> at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()<br>--- End of stack trace from previous location where exception was thrown ---<br> at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeFilterPipelineAsync>g__Awaited|19_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)<br> at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)<br> at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)<br> 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</p>
<p> </p>
<p>需要安装包</p>
<p>执行命令:</p>
<p>sudo apt-get install libgdiplus </p>
<p>在重启API</p>
<p>dotnet FAST.API.Core.dll --urls http://*:5000</p>
<p> </p>
<p>3、开启外网访问</p>
<p> </p>
<p>iptables -A INPUT -p tcp --dport 5000:6000 -j ACCEPT</p>
<p>我这设置了,没有效果</p>
<p>重启电脑生效了</p>
<p>其他:</p>
<p>查看端口占用:</p>
<p>netstat -anp |grep 3306</p>
<p> </p><br><br>
来源:https://www.cnblogs.com/piaoxuewuming/p/15574502.html
頁:
[1]