Skip to content
Advertisement

Permission Denied when trying to read file w/644 permission

I am trying to write a PHP script for a Web server (lighttpd) to read a file in another user. The Web server runs under user http:

http      1929   336  0 Nov20 /usr/bin/lighttpd -D -f /etc/lighttpd/lighttpd.conf

The file the script is trying to read has the following permissions:

-rw-r--r-- 1 pi www-data 721 Oct 30 05:20 /home/pi/bmSunday

Which I thought meant that any user can read it.

The fopen in the script results in a Permission denied:

Warning: fopen(/home/pi/bmSunday): failed to open stream: Permission denied in /srv/http/p1/index.php

I am running Arch Linux.

uname -r 

displays:

4.4.32-2-ARCH

What permissions do I need to set on the file so that user http is allowed to read it?

By the way, am I correct in assuming I can also test the permission via:

sudo -u http cat /home/pi/bmSunday

Using the above command, the result is:

cat: /home/pi/bmSunday: Permission denied

Advertisement

Answer

The permissions on the directory are probably wrong, http probably doesn’t have execute permission. Add world execute permissions:

chmod o+x /home/pi
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement