I\'m running Symfony 3.1.5 on a Ubuntu 14.04, PHP 7.1 and Apache 2.4.23 stack managed by Vagrant 1.8.6/VirtualBox 5.1.6. I\'m trying to use a simple controller I\'ve made to
If you are using NFS for the synced folder, then the UID and GID of all files in it will be the UID and GID of the host user running Vagrant, and might not match the UID and GID of the vagrant
user on the guest. For example, I have:
-rw-r--r-- 1 501 dialout 5.1K Oct 29 15:14 Vagrantfile
501
is the UID of my user on the Mac, and there is no corresponding user on the guest. dialout
is the group on the guest that matches the staff
group that’s my primary group on the Mac.
Although you have permissions to read and write all files in the synced folder, when PHP checks the UID of the session file owner, it doesn’t match the user PHP is running as, and it blocks the access as a security measure.
You can use the vagrant-bindfs plugin to work around this:
vagrant-bindfs
A Vagrant plugin to automate bindfs mount in the VM. This allow you to change owner, group and permissions on files and, for example, work around NFS share permissions issues.
Here’s what worked for me:
vagrant plugin install vagrant-bindfs
In your Vagrantfile:
config.vm.synced_folder '.', '/vagrant', disabled: true
config.vm.synced_folder '.', '/vagrant-nfs', type: 'nfs'
config.bindfs.bind_folder '/vagrant-nfs', '/vagrant'
Run vagrant reload
And it works:
-rw-r--r-- 1 vagrant vagrant 5.1K Oct 29 15:45 Vagrantfile