In my ubuntu i have configured cgi in /var/www/html/webcgi so when files uploaded on that webcgi its not get executed , it shows me internal server error so i need to chmod. As webcgi is chowned www-data and uploader. so i tried to chmod 777 with uploader when files get uploaded, i mean the uploader use php chmod() function to give permission but thats not execute.. but when i chmod it from termial and chown it as www-data it gets executed.. is there any way to chmod files when it get uploaded. i thought to make a cronjob but that's not a good way..


  • 1
    "chmod 777" has never been a correct solution to any question regarding permissions. Never. You either need a sticky bit (like /tmp/) or the "others" should be at least "5" but preferably even "0". Files you download from a website should never be set to execute. You should parse them through an executable.
    – Rinzwind
    Jul 14, 2017 at 8:57

1 Answer 1


Use ACLs:

setfacl -dm "u:www-data:rwx" /path/to/dir

Now www-data has access to this directory, also files created by www-data will inherit its permissions.

based on how your web server has been configured you might want to do this using www-data group:

setfacl -dm "g:www-data:rwx" /path/to/dir

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.