13

None of my website images are loaded, although paths are correct. In my Apache logs, I have plenty of :

(13)Permission denied: [client 87.231.108.18:57108] AH00035: access to 
my/file/path/some-photo.jpg denied because search permissions are missing 
on a component of the path

Within httpd.conf file :

User apache
Group apache

All the way down to my website directory, folders are owned by apache:apache, with chmod set to 774 all the way down.

SELinux boolean httpd_can_network_connect has been is On.

I am using a .htaccess file to redirect my domain name to the appropriate directory. I suspect this might be cause the issue but... this is nothing more than a gut feeling.

I do need help, any suggestion is most welcomed. Many thanks!

EDIT Content of the .htaccess file :

RewriteEngine On
Options +FollowSymLinks

RewriteCond %{HTTP_HOST} ^domain\.com$ [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]

RewriteCond %{HTTP_HOST} www\.domain\.com
RewriteRule (.*) /domain/$1 [L]
Alexandre Bourlier
  • 3,972
  • 4
  • 44
  • 76

7 Answers7

23

I finally found it! Thanks a ton Justin lurman to poiting out the .htaccess file. It made me see that Wordpress didn't have the right to edit my .htaccess file anymore. That was even more weird because I was 100% sure that permissions were good (even way too permissive if you ask me).

So I looked into SElinux, as I know it can play tricks on me at times and I was right. Issuing the following command solved it :

chcon -R --type=httpd_sys_rw_content_t wp-content/

I hope that helps someone else :)

Alexandre Bourlier
  • 3,972
  • 4
  • 44
  • 76
13

In my case the containing folder did not have the +x permission, changing it to 755 did the trick.

Radek
  • 263
  • 3
  • 10
7

What worked for me was that all component directories in the path needed execute permissions for all

so if the path of the website is /home/user1/public_html/docroot

chmod +x /home/user1/
chmod +x /home/user1/public_html/
chmod +x /home/user1/public_html/docroot/
GiorgosK
  • 7,647
  • 2
  • 29
  • 26
4

Or you can run

find . -type d -exec chmod 755 {} \;
find . -type f -exec chmod 644 {} \;

In those folders...

Aleksandar Pavić
  • 3,143
  • 1
  • 34
  • 36
4
setsebool -P httpd_enable_homedirs 1

chcon -R -t httpd_sys_content_t /home/user/public_html
Sven Eberth
  • 3,057
  • 12
  • 24
  • 29
Fabien Thetis
  • 1,666
  • 15
  • 11
  • I was getting the exact error in the OP, despite the search permissions, both chmod and SELinux chcon, set properly on every component of the path. Spent hours, constantly finding the same answers to set permissions on the path components using chmod and chcon. Without an explanation on this answer, I would've likely skipped it as not addressing the path components issue in the error message, if I hadn't been so desperate for something different. Despite the error message pointing to those path components, it turned out that setting the SELinux option httpd_enable_homedirs resolved it. Thanks! – Rob at TVSeries.com May 29 '21 at 18:41
1

On macOS it might be caused by a user group permission issue.

Go to httpd.conf file (located at /usr/local/etc/httpd if Apache is installed by Homebrew). Find <IfModule unixd_module> and change the value in front of User to your computer username (that you log in with). Restart Apache.

This needs to be done to PHP-FMP as well if you are using that with Apache. Find php-fpm.conf file (usually located at /usr/local/etc/php/7.x/ and find the pool definitions:

uncomment include=/usr/local/etc/php/7.x/php-fpm.d/*.conf if commented and save the file. now open the recently uncommented file and find user = and change the value of user to your computer username. Now restart PHP service.

Vahid Amiri
  • 10,769
  • 13
  • 68
  • 113
1

Just one command:

sudo setsebool -P httpd_enable_homedirs 1

Helps for me.

Sven Eberth
  • 3,057
  • 12
  • 24
  • 29
  • Already [metioned](https://stackoverflow.com/a/43053662/6670491). Invest some time in the site and you will gain sufficient [privileges](//stackoverflow.com/privileges) to upvote answers you like, which is the Stack Overflow way of saying thank you and marking helpful answer. – HardcoreGamer Aug 23 '21 at 09:42