【问题标题】:kestrel-dotnetapp.service: Failed at step EXEC spawning /usr/local/dotnet: Permission deniedkestrel-dotnetapp.service:在步骤 EXEC 生成 /usr/local/dotnet 时失败:权限被拒绝
【发布时间】:2020-09-23 21:40:50
【问题描述】:

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

根据微软文档/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 出现错误。

6 月 4 日 22:51:28 主机名 systemd[1827]:kestrel-dotnetapp.service:无法执行命令:权限被拒绝
6 月 4 日 22:51:28 主机名 systemd [1827]:kestrel-dotnetapp.service:在步骤 EXEC 生成 /usr/local/dotnet 时失败:权限被拒绝
-- 主题:无法执行进程 /usr/local/dotnet
-- 定义者: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

【问题讨论】:

    标签: linux asp.net-core .net-core centos kestrel-http-server


    【解决方案1】:

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

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

    【讨论】:

      【解决方案2】:

      经过数小时的搜索......上面的答案是有效的 即使对于具有默认安装和具有自定义发布文件夹的默认用户 pi 的 Dotnet 5.0 应用程序:

      [Service]
       
      WorkingDirectory=/home/pi/myPublishDirectory
      
      ExecStart=/home/pi/.dotnet/**dotnet** /home/pi/myPublishDirectory/MyApplication.dll
      
      User=pi
      ...
      

      【讨论】:

        猜你喜欢
        • 2013-03-03
        • 1970-01-01
        • 1970-01-01
        • 2017-08-02
        • 2011-03-24
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-07-28
        相关资源
        最近更新 更多