即使session.gc_probability设置为0,Symfony也会在Ubuntu 14.04上调用PHP垃圾回收器 [英] Symfony calls the PHP garbage collector on Ubuntu 14.04 even when session.gc_probability is set to 0

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



< h2>以前的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 = 0

Does 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 Value
session.gc_divisor      1000          1000
session.gc_maxlifetime  86400         86400
session.gc_probability  0             0

I 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 3

However, 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.yml
framework:
    session:
        gc_probability: null

https://symfony.com/doc/current/components/http_foundation/session_configuration.html#configuring-garbage-collection

Previous 2.x versions

To change this add the following to your config.yml

framework:
    session:
        gc_probability: 0

Then clear the dev cache

php app/console cache:clear

This 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垃圾回收器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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