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

查看:64
本文介绍了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

在此目录中,我确实看到了属于我的Apache的www-data拥有的会话文件,并且该应用程序运行正常. 这让我想知道,会话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_probability设置为0

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天全站免登陆