1

What permissions do I need to set up on a directory in order to make it writable by php?

By "writable", I mean copying and creation of new files within that directory automatically by php itself.

I'm testing this on a free host, and the default permissions are 755.

When I try executing a php script, that attempts to create another subfolder of that directory, and copy certain files in it, and it fails.

If I set it up to 777, it works fine, but I assume that doesn't work on all Apache versions because of security reasons?

Also, when creating new files, does php act as the "owner"?

DavidPostill
  • 7,734
  • 9
  • 41
  • 60
lakumba
  • 19
  • 1
  • 5

1 Answers1

0

Whatever process that runs the PHP interpreter should should have a user account associated with it. Only that user needs write permission in the directory. So to answer your last question, it's usually www-data or apache that is the owner of that file.

Permission of 777 will work because it allows everyone to read, write and execute that directory but depending on your application this might be a security hole.

hyde
  • 2,525
  • 4
  • 27
  • 49