I'm using vagrant with a synced_folder
development.vm.synced_folder "/usr/local/src/www", "/var/www", owner: "www-data", group: "www-data"
Is there a way to change the owner of a sub directory of the /var/www, say /var/www/images?
I'm using vagrant with a synced_folder
development.vm.synced_folder "/usr/local/src/www", "/var/www", owner: "www-data", group: "www-data"
Is there a way to change the owner of a sub directory of the /var/www, say /var/www/images?
Obviously a very late answer but this behavior is still true for Vagrant and some mount types. The docs states this for mount owner setting
owner (string) - The user who should be the owner of this synced folder. By default this will be the SSH user. Some synced folder types do not support modifying the owner
Here: https://www.vagrantup.com/docs/synced-folders/basic_usage#owner
This means that in many cases we need to do some workaround that grants write permission but don't involve changing owner. If it's a development environment perhaps you could be a little YOLO and grant write permissions for all to the files/folders in the directory
A messy quick-fix that the ABSOLUTLY is only for development/testing
sudo chmod -R 1777 /var/www/images
A more cleaner way would to use "find" to change directories only
find /var/www/images -type d -exec chmod 755 {} \;
Again, for development/testing only
EDIT:
Parhaps the easiest fix is to set permissions in mount options for the entire webroot.
config.vm.synced_folder "./", "/var/www/example.com", type: "virtualbox", owner: "vagrant", group: "vagrant", mount_options: ["fmode=776"]
The above code will still have user Vagrant as owner but allows all users, including www-data, to write to the entire structure. Not very safe, but working.