PHP 5.3 和会话文件夹的问题 [英] Issues with PHP 5.3 and sessions folder

查看:18
本文介绍了PHP 5.3 和会话文件夹的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近升级到 PHP 5.3,从那时起我收到(零星的)错误消息,表明 Apache(或可能是会话文件的清理者)对存储会话的文件夹没有权限.
这种情况是随机发生的,不能用精确的步骤重现,这让我猜测它是会话清理器.
任何人都对此类错误有任何经验?

I recently upgraded to PHP 5.3 and since then I get (sporadic) error messages which indicate Apache (or may be the cleaner of the session files) has no permissions to the folder where the sessions are stored.
This happens randomly and can't be reproduced with exact steps, which led me to guess it is the session cleaner.
Any one has any experience with such errors?

错误消息(在 session_start() 行上触发)是:

The error message (which is fired on the session_start() line) is:

ps_files_cleanup_dir:opendir(/var/lib/php5) 失败:权限被拒绝.

ps_files_cleanup_dir: opendir(/var/lib/php5) failed: Permission denied.

会话目录上的 ls -ltr 给出:

ls -ltr on the session directory gives:

drwx-wx-wt  2 root          root          4096 2010-05-25 12:39 php5

在这个目录中,我确实看到了 www-data 拥有的会话文件,它是我的 Apache,并且该应用程序运行良好.这让我想知道,会话 GC 在哪个用户下运行?

Inside this directory I do see session files owned by www-data which is my Apache, and the app does work fine. Which makes me wonder, under which user does the session GC runs?

推荐答案

修复: 在你的 php.ini 设置 session.gc_probability0

The fix: In your php.ini set session.gc_probability to 0

原因我相信我在这里找到了答案 http://somethingemporium.com/2007/06/obscure-error-with-php5-on-debian-ubuntu-session-phpini-garbage

The cause I believe I found the answer here http://somethingemporium.com/2007/06/obscure-error-with-php5-on-debian-ubuntu-session-phpini-garbage

本质上,垃圾收集设置为由某些系统(即 Ubuntu/Debian)上的 cron 作业完成.一些 php ini 可执行文件(如 php-cli)也尝试进行垃圾收集,这会导致您遇到错误.

Essentially, the garbage collection is set up to be done by cron jobs on some systems (i.e. Ubuntu/Debian). Some php ini executables like php-cli also try to do garbage collection and that results in the error you got.

这篇关于PHP 5.3 和会话文件夹的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆