session_start挂起 [英] session_start hangs

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

问题描述

自从您每次进行session_start几个小时后,我们的服务器就挂起了.

since a few hours our server hangs every time you do a session_start.

出于测试目的,我创建了一个如下所示的脚本:

For testing purposes i created a script which looks like this:

<?php
session_start();
?>

从控制台调用它会挂起,甚至无法使用ctrl-c停止它,只能杀死-9作品.通过Apache调用它也是一样. /var/lib/php/session/保持空白,但权限绝对可以,www可以写,并且对所有父文件夹都具有读取权限.

Calling it from the console hangs and it can't even be stopped with ctrl-c, only kill -9 works. The same for calling it via Apache. /var/lib/php/session/ stays empty but permissions are absolutely fine, www can write and also has read permissions for all parent folders.

根据管理员的说法,服务器上未进行任何更改,也没有为会话注册特殊代码.服务器是CentOS 4或5,昨天一切运行正常.我们重新启动了服务器并更新了PHP,但是没有任何变化.

According to the admins there were no changes made on the server and there is no special code registered for sessions. The Server is CentOS 4 or 5 and yesterday everything was working perfectly. We rebooted the server and updated PHP, but nothing changed.

我已经没有想法了,有什么建议吗?

I've ran out of ideas, any suggestions?

更新

我们通过将项目移至另一台服务器解决了此问题,因此尽管问题仍然存在于一台服务器上,所以不再需要解决方案了. 不过,如果有人对将来遇到类似问题的想法有所了解,我将保持开放的态度.

We solved this problem by moving the project to another server, so while the problem still exists on one server there is no immediate need for a solution anymore. I will keep the question open in case someone has an idea for others having a similar problem in the future, though.

推荐答案

有很多原因,以下是其中的一些原因:

There are many reasons for that, here are a few of them:

A..可以单独打开会话文件. 如果出于某种原因未正确释放文件锁,则会导致session_start()无限期挂起在以后的任何脚本执行中. 解决方法:使用session_set_save_handler()并确保写入功能使用fopen($file, 'w') instead of fopen($file, 'x')

A. The session file could be opened exclusively. When the file lock is not released properly for whatever reason, it is causing session_start() to hang infinitely on any future script executions. Workaround: use session_set_save_handler() and make sure the write function uses fopen($file, 'w') instead of fopen($file, 'x')

B.切勿在php.ini文件中使用以下内容(将文件熵保存为"/dev/random"),这将导致您的session_start()挂起:

B. Never use the following in your php.ini file (entropie file to "/dev/random"), this will cause your session_start() to hang:

<?php
ini_set("session.entropy_file", "/dev/random");
ini_set("session.entropy_length", "512");
?>

C. session_start()需要一个目录来写入.

C. session_start() needs a directory to write to.

您可以使Apache plus PHP以普通用户帐户运行.然后,Apache当然必须侦听80以外的其他端口(例如8080).

You can get Apache plus PHP running in a normal user account. Apache will then of course have to listen to an other port than 80 (for instance, 8080).

请确保执行以下操作: -创建一个临时目录PREFIX/tmp -将php.ini放入PREFIX/lib -编辑php.ini并将session.save_path设置为您刚刚创建的目录

Be sure to do the following things: - create a temporary directory PREFIX/tmp - put php.ini in PREFIX/lib - edit php.ini and set session.save_path to the directory you just created

否则,您的脚本似乎在session_start()上挂起".

Otherwise, your scripts will seem to 'hang' on session_start().

这篇关于session_start挂起的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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