简体   繁体   中英

Service permission denied - Fedora 31

I am currently working on a website that will run .net code using this guide:

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

And this guide to install .net core SDK (I installed 2.1 and 3.1 while troubleshooting):

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

I am trying to configure the apache proxy server to send requests to the Kestrel server but I am having issues with my service at /etc/systemd/system/kestrel-helloapp.service.

My service's code is:

[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

The service status is:

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'.

There are three main differences in my service code in comparison to the guides code:

1st: I have removed to auto restart, so it dosen't bog down my machine.

2nd: I have changed the ExecStart=/usr/local/dotnet to ExectStart=/usr/shared/dotnet , I have done this because my .net installation isn't at that location for some reason that eludes me.

3rd: I have changed the User=apache to User=root in an attempt to troubleshoot, the only user on my machine is root as this machine is just for school purposes.

I have also changed the SELinux settings on my machine to permissive and finally disabled in an attempt at troubleshooting.

I'm still new to this and none of this was seen in class, so go easy on me.

Thanks you for your time/answers.

Systemd has restrictions on where executed files are located. I'm not an expert in this field but there is a workaround on this issue. You can edit /etc/selinux/config and change line:

SELINUX=enforcing with SELINUX=permissive ,

then restart the system and the service from systemd will start.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM