7

Every time I upgrade php (via yum upgrade) on my CentOS box, my /var/lib/session folder ownership becomes root:apache with 600 permissions. I use nginx as my web server. This breaks my site and prevents sessions from being stored.

The fix is simply to chown nginx:nginx the folder. But I have to manually do this every time yum updates php.

I imagine the problem stems from the fact that when I initially set the box up I ran apache. Where can I change this config to "nginx" to fix this issue? I had a look in php.ini but couldn't see anything relevant in there. The session directory is specified, but nothing about the user.

2
  • This is most likely a function of the RPM package being installed via yum. The php RPM that is installed is set to configure Apache HTTPD, not nginx. I'm not sure there's any way to get around it.
    – ScoPi
    Mar 20, 2014 at 5:23
  • That was the conclusion I came to after doing some further googling when I got no responses. The "best" option seems to be to run nginx under an apache user/group, which seems a bit of a dirty kludge to me.
    – Codemonkey
    Mar 24, 2014 at 13:02

1 Answer 1

6

The best way is to use a different session directory for each user/pool.

In php-fpm.d/www.conf (already altered to change the user), and as explained in the comment.

user = foo

; Set session path to a directory owned by process user
php_value[session.save_handler] = files
php_value[session.save_path]    = /var/lib/php/foo/session
php_value[soap.wsdl_cache_dir]  = /var/lib/php/foo/wsdlcache

Thus, these new directories won't be changed on next update.

BTW, there is absolutely no need to change the user, you can use nginx and keep fpm running as apache (especially as most of packaged web applications rely on this)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .