本文介绍了即使session.gc_probability设置为0,Symfony也会在Ubuntu 14.04上调用PHP垃圾回收器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 $ b code> session.gc_probability = 0 有谁知道如何防止这种情况发生? / p> 即时通讯错误讯息: 注意:SessionHandler :: gc( ):ps_files_cleanup_dir:opendir(/ var / lib / php5)失败:权限在/<path-to-my-site> /var/cache/dev/classes.php中被拒绝(13)432 FROM PHPINFO(): 指令本地价值主值 session.gc_divisor 1000 1000 session.gc_maxlifetime 86400 86400 session.gc_probability 0 0 我知道我可以将www-data用户权限赋予 / var / lib / php5 文件夹或将 session.save_path 更改为 www-data 用户已经可以访问了,但是我想知道为什么这个过程甚至会在被禁用时被调用。我发现它,我猜测在使用 app_dev.php 时,symfony的最新版本默认覆盖了这个。 Symfony FrameworkBundle正在设置 session.gc_probability = 1 。 从Symfony 3开始 但是,有些操作系统会自行处理会话并将session.gc_probability变量设置为0,以阻止PHP执行垃圾回收。这就是为什么Symfony现在将此值覆盖为1。 如果您希望使用php.ini中设置的原始值,请添加以下配置: #config.yml 框架:会话: gc_probability:null https://symfony.com/doc/current/components/http_foundation/session_configuration.html#configuring-garbage-collection 以前的2.x版本 要改变它,请在 config.yml framework: session: gc_probability:0 然后清除dev缓存 php app / console cache:clear 这是显示 gc_probability 默认值的地方到 1 。为什么他们不只是从php.ini设置中读取im不知道。 http://symfony.com/doc/2.5/reference/configuration/framework.html#gc-概率 As the title state for some reason my Symfony 2.5 Application is calling the php garbage collector even when all of my php.ini files have:session.gc_probability = 0Does anyone know how to prevent this from happening?Error message im getting:Notice: SessionHandler::gc(): ps_files_cleanup_dir: opendir(/var/lib/php5)failed: Permission denied (13) in /<path-to-my-site>/var/cache/dev/classes.php line 432 FROM PHPINFO():Directive Local Value Master Valuesession.gc_divisor 1000 1000session.gc_maxlifetime 86400 86400session.gc_probability 0 0I know that i can just give the www-data user permission to the /var/lib/php5 folder or change the session.save_path to somewhere that the www-data user has access to already but i want to know why this process is even getting called when it should be disabled. 解决方案 I found it, I guess the latest version of symfony is overwriting this by default when using the app_dev.php. The Symfony FrameworkBundle is setting the session.gc_probability = 1.As of Symfony 3However, some operating systems do their own session handling and set the session.gc_probability variable to 0 to stop PHP doing garbage collection. That's why Symfony now overwrites this value to 1.If you wish to use the original value set in your php.ini, add the following configuration:# config.ymlframework: session: gc_probability: nullhttps://symfony.com/doc/current/components/http_foundation/session_configuration.html#configuring-garbage-collectionPrevious 2.x versionsTo change this add the following to your config.ymlframework: session: gc_probability: 0Then clear the dev cachephp app/console cache:clearThis is where it shows the gc_probability defaulted to 1. Why they dont just read from the php.ini settings im not sure.http://symfony.com/doc/2.5/reference/configuration/framework.html#gc-probability 这篇关于即使session.gc_probability设置为0,Symfony也会在Ubuntu 14.04上调用PHP垃圾回收器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
09-25 20:07