0

I have a PHP Script running on Linux that requires 777 Permission to write into folders but this permission is such a risky one is there a way out to avoid that permission instead of the ability to write?

Thanks

CatChMeIfUCan
  • 569
  • 1
  • 7
  • 26

1 Answers1

2

Make that directory owned by your php script, likely by chown for www-data:www-data, and then assign 755, so only web user can write to it. Obviously, block directory listing on your web server for that directory.

  • can you be more specific? – CatChMeIfUCan Feb 28 '18 at 23:10
  • 1
    @CatChMeIfUCan - imagine that php script writes to /var/www/foo, then I would do: sudo chown www-data:www-data /var/www/foo, followed by sudo chmod 755 /var/www/foo, followed by editing /etc/apache2/apache2.conf from here: https://stackoverflow.com/a/31445273/2001405 – user2001405 Mar 01 '18 at 21:11