gpt4 book ai didi

linux - kestrel-dotnetapp.service : Failed at step EXEC spawning/usr/local/dotnet: Permission denied

转载 作者:行者123 更新时间:2023-12-03 09:51:28 24 4
gpt4 key购买 nike

我正在尝试使用 MS enter 中给出的步骤在 Centos8 中安装 .NET Core(3.1) 应用程序.

根据 Microsoft 文档的服务文件 /etc/systemd/system/kestrel-dotnetapp.service

[Unit]  
Description= .NET Web API App for centos

[Service]
WorkingDirectory=/var/Application/netcoreapp31
ExecStart=/usr/local/dotnet /var/Application/netcoreapp31/helloapp.dll
Restart=always
# Restart service after 10 seconds if the dotnet service crashes:
RestartSec=10
KillSignal=SIGINT
SyslogIdentifier=dotnetapp
User=user
Environment=ASPNETCORE_ENVIRONMENT=Production
Environment=DOTNET_PRINT_TELEMETRY_MESSAGE=false

[Install]
WantedBy=multi-user.target

当我这样做时 > sudo systemctl start kestrel-dotnetapp.service 出现错误。

Jun 04 22:51:28 hostname systemd[1827]: kestrel-dotnetapp.service: Failed to execute command: Permission denied
Jun 04 22:51:28 hostname systemd[1827]: kestrel-dotnetapp.service: Failed at step EXEC spawning /usr/local/dotnet: Permission denied
-- Subject: Process /usr/local/dotnet could not be executed
-- Defined-By: systemd

ls -la 下方查找:

[user@hostname dotnet]$ ls -la
total 108
drwxr-xr-x. 4 root root 94 Apr 22 09:34 .
drwxr-xr-x. 14 root root 154 Jun 4 21:11 ..
-rwxr-xr-x. 1 root root 73048 Apr 22 09:32 dotnet
drwxr-xr-x. 3 root root 17 Apr 22 09:34 host
-rw-r--r--. 1 root root 1116 Apr 22 09:29 LICENSE.txt
drwxr-xr-x. 4 root root 67 Apr 22 09:34 shared
-rw-r--r--. 1 root root 31330 Apr 22 09:29 ThirdPartyNotices.txt

我的应用交付文件夹

[user@hostname Application]$ ls -la
total 8
drwxr-xr-x. 3 root root 26 Jun 4 20:53 .
drwxr-xr-x. 22 root root 4096 Jun 4 20:53 ..
drwxr-xr-x. 2 777 user 4096 Jun 4 20:45 netcoreapp31

最佳答案

当我们将 ExecStart 的路径更改为 ExecStart=/usr/local/dotnet/dotnet 时,发现服务正在启动。不知道为什么微软博客说直到 ExecStart=/usr/bin/dotnet 就足够了!

PS:另外如果Linux是SE服务文件不应该在/home目录

关于linux - kestrel-dotnetapp.service : Failed at step EXEC spawning/usr/local/dotnet: Permission denied,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62202518/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com