How would I, with security in mind, allow www-data to create directories within /var/www/html/assets/img and its sub-directories?

I have a PHP script that automatically creates directories with 777 permissions, but www-data currently doesn't have the required permissions to allow that.

1 Answer 1


Try changing the owner and group of that directory to www-data and setting permissions for owner/group to rwx

sudo chown -R www-data:wwwdata /var/www/html/assets/img
sudo chmod -R 755 /var/www/html/assets/img

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.