Jeroen1000 Posted September 28, 2009 Share Posted September 28, 2009 My apologies for the somewhat unclear topic title. I've build (with some help from phpfreaks ) a script that reads a directory and calculates its size. It does a few other things but that's not very important. But when I try to perform this trick outside Apache's www directory I get a: Warning: opendir(/root/backups/backup.jeroen/) [function.opendir]: failed to open dir: Permission denied in /var/www/Deltacopy/index.php on line 107 The easy way out is running Apache as root (that solution works), which would be a very bad idea. Is there a way I can give the script read privileges to a folder? Cheers, Jeroen Link to comment https://forums.phpfreaks.com/topic/175802-php-script-with-read-privileges-outside-apaches-www-directory/ Share on other sites More sharing options...
trq Posted September 28, 2009 Share Posted September 28, 2009 Is there a way I can give the script read privileges to a folder? Yes, make sure the Apache user has sufficient permissions to read it. Link to comment https://forums.phpfreaks.com/topic/175802-php-script-with-read-privileges-outside-apaches-www-directory/#findComment-926378 Share on other sites More sharing options...
trq Posted September 28, 2009 Share Posted September 28, 2009 Sorry, that wasn't real helpful after all. To do the above you need to either... a) Make the directory be owned by apache then set it u+w b) Make the directory belong to the apache group then set it g+w c) Make it readable by everyone (o+w) Link to comment https://forums.phpfreaks.com/topic/175802-php-script-with-read-privileges-outside-apaches-www-directory/#findComment-926381 Share on other sites More sharing options...
Jeroen1000 Posted September 29, 2009 Author Share Posted September 29, 2009 No need to apologize, I know noobs can be bothersome sometimes After some googling I managed to complete the steps you listed. Thanks for putting me on track as I was looking in the wrong direction to solve this. I also came up with an alternative approach. A bash script puts the size (in bytes) in a file in a special directory Apache can read. I simply read the first line of that file and convert the number to something human readable. Might be of use for someone else looking for something similar. Link to comment https://forums.phpfreaks.com/topic/175802-php-script-with-read-privileges-outside-apaches-www-directory/#findComment-926897 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.