5

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

Community
  • 1
  • 1
Juri Sinitson
  • 1,445
  • 1
  • 14
  • 18

3 Answers3

3

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?

Juri Sinitson
  • 1,445
  • 1
  • 14
  • 18
  • You saved me!! Happening to me with SF3+PHP7+Vagrant, probably it is related to the fact that `/vagrant` is shared with the host and the host is windows. -- **NOTE:** Of course this differs between devel and production, so consider adding the `save_path` into a parametrizable thing in `parameters.yml` like `session_save_path: "/var/lib/php/sessions"` and `session_save_path: "%kernel.root_dir%/../var/sessions/%kernel.environment%"` in the devel and production parameters respectively and then use `save_path: "%session_save_path%"` in the `config.yml`. – Xavi Montero Dec 09 '16 at 12:32
  • I still don't get the reason why this helps as permissions are good on `var/sessions` as well. – Mantas Jan 05 '17 at 09:27
0

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
Terry Lin
  • 2,529
  • 22
  • 21
-1

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.

Xavi Montero
  • 9,239
  • 7
  • 57
  • 79