服务权限被拒绝-Fedora 31

时间:2020-03-16 01:08:32

标签: asp.net-mvc apache fedora web-development-server kestrel-http-server

我目前正在使用本指南运行.net代码的网站上:

https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/linux-apache?view=aspnetcore-3.1

这是安装.net core SDK的指南(我在故障排除时安装了2.1和3.1):

https://docs.microsoft.com/en-ca/dotnet/core/install/linux-package-manager-fedora31

我正在尝试配置apache代理服务器以将请求发送到Kestrel服务器,但是/etc/systemd/system/kestrel-helloapp.service上的服务出现问题。

我的服务代码是:

[Unit]
Description=Started service

[Service]
WorkingDirectory=/var/www/html/PublishedVersion
ExecStart=/usr/share/dotnet /var/www/html/PublishedVersion/Website.dll
KillSignal=SIGINT
SyslogIdentifier=dotnet-example
User=root
Enviroment=ASPNETCORE_ENVIROMENT=Production

[Install]
WantedBy=multi-user.target

服务状态为:

Mar 15 19:37:38 localhost.localdomain systemd[1]: Started service
Mar 15 19:37:38 localhost.localdomain systemd[1706]: kestrel-helloapp.service: Failed to execute command: Permission denied
Mar 15 19:37:38 localhost.localdomain systemd[1706]: kestrel-helloapp.service: Failed at step EXEC spawning /usr/share/dotnet: Permission denied
Mar 15 19:37:38 localhost.localdomain systemd[1]: kestrel-helloapp.service: Main process exited, code=exited, status=203/EXEC
Mar 15 19:37:38 localhost.localdomain systemd[1]: kestrel-helloapp.service: Failed with result 'exit-code'.

与指南代码相比,我的服务代码有三个主要区别:

第一:我已经删除了自动重启功能,因此它不会使我的机器停顿下来。

2nd:我将ExecStart=/usr/local/dotnet更改为ExectStart=/usr/shared/dotnet,之所以这样做,是因为由于某些原因,我的.net安装不在该位置。

第3次:为了进行故障排除,我将User=apache更改为User=root,由于这台计算机仅用于学校目的,因此我的计算机上唯一的用户是root。

我还已将计算机上的SELinux设置更改为宽松的,最后被禁用,以尝试进行故障排除。

我还是这个新手,上课没见过,所以请放轻松。

感谢您的时间/回答。

1 个答案:

答案 0 :(得分:1)

Systemd对执行文件的位置有限制。我不是该领域的专家,但是在此问题上有解决方法。您可以编辑/etc/selinux/config并更改行:

SELINUX=enforcingSELINUX=permissive

然后重新启动系统,并且systemd中的服务将启动。