-2

Intro:

I am sorry to be asking for help when there's loads of that on the internet, however I'm not Linux savvy.

Problem:

I've installed apache2 and PHP5 under debian, and uses of PHP fopen() function produce typical:

Warning: fopen(/some/where/some.txt): failed to open stream: Permission denied in /some/file/location/of/script/index.php on some line

Hoped response:

I would be very grateful if anyone could kindly supply me with a secure/minimum required solution to make it work, and even better if that would be explained as well.

Weak assumption:

It is extremely likely that some folders or configurations require correct permissions set, however I am in a dark forest when it comes to that.

Notes:

  • Apache is compiled and installed from source. PHP is compiled and
  • installed from source, without default php.ini
  • Above should be considered with me not being Linux savvy and not getting permissions.
Håkan Lindqvist
  • 35,011
  • 5
  • 69
  • 94
Bob
  • 81
  • 1
  • 6

1 Answers1

1

It's likely to be nothing to do with your Apache/PHP setup however you've provided no information about how these are configured. Most likely the user the PHP script is running a does not have permission to open the files. Without knowing how it's configured I can't tell you how to get this information (ps auxwww | grep php might show the user). Nor have you told us what the permissions / ownership on the files are (chmod a+wr filename.txt makes a filereadable/writeable by any user - but that seriously compromises security).

How you make your files accessible and secure depends on your security policy but knowing nothing about the machine / it's purpose nor how it is configured would make it impossible even with your security policy.

A further consideration is that storing data in flat files, accessed directly via PHP is almost always a very bad idea. It does not scale and can lead to deadlocks and race conditions.

symcbean
  • 21,009
  • 1
  • 31
  • 52