1

I'm trying to make my website, hosted on my CentOS 8, load up background.png file that is located on the same directory as rest of the website (/var/www/html) but the website refuses to load it and when I go directly to localhost/background.png I get an access denied -error.

On the error log I get "AH00132: file permissions deny server access". My stylesheet and PHP files on the same directory work fine.

I've looked up different ways to solve this online but I just can't seem to fix it and it has gotten really frustrating. I should only need to use one image (at least for now) for my website so I could theoretically use one that is hosted online but for a couple of reasons I prefer not to.

Things I've tried:

  • Used chmod 755 to the .png file and even used chown/chmod --reference from an accessible file
  • have mod-mime "AddType image/png .png"
  • don't have .htaccess other than some password related stuff for my phpmyadmin
  • added "AllowOverride All, Allow from all, Require all granted" on the httpd conf under the /var/www/html -directory bracket
  • restarted httpd
  • cleared the browser

Any other ideas? Outside of basics I'm a newbie when it comes to Linux so don't use fancy terms pls :p

EDIT:

Issue was on SELinux. After following this https://superuser.com/a/988862 guide I managed to let SELinux allow read access to the file. Thanks for the help!

5
  • 1
    Is SELinux enabled on the server?
    – Ángel
    Oct 25, 2020 at 18:56
  • @Ángel Oh, I didn't even realize I had it enabled. I disabled it to see if that's what's causing it and it started working. Thank you so much!! Any clue why it didn't give me access just to the .png file?
    – Jaacobbi
    Oct 25, 2020 at 19:03
  • You should look how was the file tagged, then fix the configuration or relabel the file.
    – Ángel
    Oct 25, 2020 at 19:06
  • Ah, I got it work. I used some audit2allow cmd to allow the read access. Thank you very much for the swift help!
    – Jaacobbi
    Oct 25, 2020 at 19:35
  • I have posted a brief answer with the above comments so that it can be accepted.
    – Ángel
    Oct 25, 2020 at 19:44

1 Answer 1

0

You should check if SELinux is enabled on that server and in that case if it may be the one blocking access to Apache. You should look how was the file tagged, then fix the configuration or relabel the file.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .