Linux kestrel-dotnetapp.service:在步骤EXEC sprowning/usr/local/dotnet时失败:权限被拒绝
我正在尝试使用MS中给出的步骤在Centos8中安装.NET Core(3.1)应用程序 符合Microsoft文档Linux kestrel-dotnetapp.service:在步骤EXEC sprowning/usr/local/dotnet时失败:权限被拒绝,linux,asp.net-core,.net-core,centos,kestrel-http-server,Linux,Asp.net Core,.net Core,Centos,Kestrel Http Server,我正在尝试使用MS中给出的步骤在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/
/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启动kestrel dotnetapp.service时
出现错误
Jun 04 22:51:28主机名systemd[1827]:kestrel-dotnetapp.service:无法执行命令:权限被拒绝Jun 04 22:51:28主机名systemd[1827]:kestrel-dotnetapp.service:在执行生成/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
当我们将ExecStart的路径更改为
ExecStart=/usr/local/dotnet/dotnet
时,发现服务正在启动。不知道为什么微软的博客上说,直到ExecStart=/usr/bin/dotnet就足够了
另外,如果Linux是SE,则服务文件不应位于/home目录中