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
Editing config/config.yml
and replacing save_path: "%kernel.root_dir%/../var/sessions/%kernel.environment%"
with save_path: /var/lib/php/sessions
fixed the error.
If you use an editor/IDE that automatically converts spaces to tabs, be sure to disable that feature before saving your changes. Failure to do so may cause a 'does not contain valid YAML' error to occur.
If Magento 2 generates this warning,
Just delete already existed session inside var/session
folder and its fixed.
Session path can't be written to since the web user and the owner of the content in the sessions folder are different and thus doesn't .
Solution is to set your /var or /var/sessions/ ownership to the web user.
chown apache:apache /var/ -R * Or: chown www-data:www-data /var/ -R *
Highest rated response is not really the best response here.
I had a similar problem and clearing my browser's cache and stored data solved the problem.
On chrome and opera you should the following:
Developer tools > Application > Clear Storage > Clear Site Data
AVOID change prod configuration for troubles that only occurs in development environment
Had the Same trouble when using Vagrant (PHP-FPM 7 + Nginx) with a sync folder (/vagrant ~ default)
Solved just put
session:
save_path: '/tmp'
on config_dev.yml inside framework entry
Just choose some place that Webserver and PHP can read/write without permission issues.