Muq
Muq

Reputation: 29

Error 503 with httpd localhost server on Fedora 35

So I switched to Fedora and wanted to install LAMP on it. So I followed this article: https://computingforgeeks.com/how-to-install-lamp-stack-on-fedora/. Everything has been installed successfully. Afterward, I wanted to change the default root directory. In order to achieve it, I edited /etc/httpd/conf/httpd.conf and have set:

DocumentRoot "/home/muq/Localhost"

User muq
Group muq

<Directory "/home/muq/Localhost">
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted
</Directory>

And now I am getting the error: 503 Service Unavailable.

If I change User and Group to default (apache) the error I get is: 403 Forbidden.

Previously I was doing the same thing with Apache on PopOS and it was working fine.

Thank you all in advance!

Upvotes: 1

Views: 720

Answers (1)

mattdm
mattdm

Reputation: 2301

Did you follow the step in the article which says to set SELinux to permissive? My guess is that you didn't, and that's what's happening: SELinux is preventing user home directory files from being served out by the web server.

You could just follow the advice in the article and just turn it off. But, I strongly recommend that you don't. The thing it's protecting you from here is a reasonable one — a misconfiguration could otherwise very easily expose personal user files to the internet. And here's the key thing: fixing this is really easy! At least as easy as the instructions for disabling SELinux in the article! You just need to do:

sudo chcon -R -t httpd_sys_content_t /home/muq/Localhost

to label that directory as one from which you want to serve httpd content. And that should do it — and still give you all the other protection of SELinux.

(You could also consider a location like /srv/www or /var/www/html as your web root, keeping your home directory out of the whole thing. These are parts of the filesystem designated for that, and to me as a former sysadmin seems cleaner. But the choice is yours.)

Upvotes: 2

Related Questions