5
votes

although the path /mnt/my-proj/app/../var/sessions/dev is accessible for both the normal user and www-data I get the following message:

Warning: session_write_close(): Failed to write session data (user). Please verify that the current setting of session.save_path is correct (/mnt/op-accounting2/app/../var/sessions/dev)

I get the message above only in dev, but not in prod. /mnt/my-proj/app/../var/sessions/dev and /mnt/my-proj/app/../var/sessions/prod have the same pemissions: 777.

The path above is mounted as following:

# mount -t vboxsf -o uid=1000,gid=33,umask=000 my-proj /mnt/my-proj;

What am I doing wrong?

I've read the following posts, but could find no solution for me:

PHP session handling errors

https://github.com/NewEraCracker/suhosin-patches/issues/3

PHP7 + Symfony 2.8, Failed to write session data

I'm using Vagrant 1.8.1 on Windows 8.1 Enterprice (64Bit) and ubuntu-xenial 16.04 in Vagrant. The provider is VirtualBox 5.0.20. The settings are mostly default ones. The path above is shared using VirtualBox GUI with full access.

Kind regards,

Juri

3

3 Answers

3
votes

SOLVED! :-)

Setting

save_path:   "/var/lib/php/sessions"

in /mnt/my-proj/app/config/config.yml solved the problem. Any adjusting of ini-Files in /etc/php/7.0/ wasn't neccessary (those files have still default values only).

But I wander why didn't I get that error message in prod?

0
votes

In addition to the previous answer from Juri Sinitson, it also solved me tweaking the VM instead of tweaking the project base.

Adding to my Vagrant bash root provisioner this line:

sed -i "s/www-data/vagrant/g" /etc/apache2/envvars
service apache2 restart

Makes the apache run as vagrant. This confers apache more power on the shared directory as it appears to the filesystem that it is the user vagrant and not the user www-data who happens to be touching there.

Maybe this is 'apparmor' related or so.

0
votes

You can just edit the configured file.

vi /etc/php/7.2/fpm/pool.d/www.conf

Then change the owner role for PHP from www-data to vagrant

user = vagrant
group = vagrant