Jump to content

Php script with read privileges outside Apache's www directory


Jeroen1000

Recommended Posts

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

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)

No need to apologize, I know noobs can be bothersome sometimes  ;D

 

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.