Reputation: 57
When i try to upload php file using vsftpd to /var/www/ and visit the file from web server i got this error,
Warning: Unknown: failed to open stream: Permission denied in Unknown on line 0
Fatal error: Unknown: Failed opening required '/var/www/.../.../public_html/d.php' (include_path='.:/usr/share/php:/usr/share/pear') in Unknown on line 0
i tried chown -R www-data:www-data /var/www after that the error got fixed but i have to do the same every time i upload a new file, is there is anyway to fix that for all new files?
Upvotes: 2
Views: 939
Reputation: 2877
The best way is to apply an ACL to the directory in question.
This will set the default so new files and folders are given the ACL, this says that the group of www-data will have read,write,execute permissions by default on all files/folders from /var/www recursively
sudo setfacl -Rdm g:www-data:rwx /var/www
This will set the ACL for existing files and folders, this says that the group of www-data will have read,write,execute from /var/www recursively for existing files and folders
sudo setfacl -Rm g:www-data:rwx /var/www
Upvotes: -1