Symfony2 生产失败
本周我们在生产环境中部署了第一个 Symfony2 网站。
服务器上开始发生奇怪的事情,但我们无法在本地重现问题。我们在其他服务器上进行了测试,也发现了相同的错误。如果有帮助的话,我们在亚马逊 EC2 上尝试了 ubuntu ami,在其他服务器上尝试了 debian。还有apache2+mod_php和nginx+php-fpm,php版本是5.3.3。 Symfony 是 2.0.9。
有些请求只是返回空白屏幕,并且在错误日志中出现以下错误:
[Sun Feb 12 17:09:30 2012] [error] [client 192.168.51.125] PHP Warning: Attempt to assign property of non-object in /var/www/itop/vendor/symfony/src/Symfony/Component/ClassLoader/ApcUniversalClassLoader.php on line 80
[Sun Feb 12 17:09:30 2012] [error] [client 192.168.51.125] PHP Warning: Attempt to assign property of non-object in /var/www/itop/app/bootstrap.php.cache on line 1152
[Sun Feb 12 17:09:30 2012] [error] [client 192.168.51.125] PHP Warning: Attempt to assign property of non-object in /var/www/itop/app/bootstrap.php.cache on line 1146
[Sun Feb 12 17:09:30 2012] [error] [client 192.168.51.125] PHP Warning: Attempt to assign property of non-object in /var/www/itop/app/bootstrap.php.cache on line 464
[Sun Feb 12 17:09:30 2012] [error] [client 192.168.51.125] PHP Warning: Attempt to assign property of non-object in /var/www/itop/app/bootstrap.php.cache on line 465
[Sun Feb 12 17:09:30 2012] [error] [client 192.168.51.125] PHP Warning: Attempt to assign property of non-object in /var/www/itop/app/bootstrap.php.cache on line 466
[Sun Feb 12 17:09:30 2012] [error] [client 192.168.51.125] PHP Warning: Attempt to assign property of non-object in /var/www/itop/app/bootstrap.php.cache on line 666
[Sun Feb 12 17:09:30 2012] [error] [client 192.168.51.125] PHP Warning: Attempt to assign property of non-object in /var/www/itop/app/bootstrap.php.cache on line 467
[Sun Feb 12 17:09:30 2012] [error] [client 192.168.51.125] PHP Warning: Attempt to assign property of non-object in /var/www/itop/app/bootstrap.php.cache on line 468
[Sun Feb 12 17:09:30 2012] [error] [client 192.168.51.125] PHP Warning: Attempt to assign property of non-object in /var/www/itop/app/bootstrap.php.cache on line 469
[Sun Feb 12 17:09:30 2012] [error] [client 192.168.51.125] PHP Warning: Attempt to assign property of non-object in /var/www/itop/vendor/symfony/src/Symfony/Component/HttpFoundation/ParameterBag.php on line 34
[Sun Feb 12 17:09:30 2012] [error] [client 192.168.51.125] PHP Warning: Attempt to assign property of non-object in /var/www/itop/vendor/symfony/src/Symfony/Component/HttpFoundation/Request.php on line 123
[Sun Feb 12 17:09:30 2012] [error] [client 192.168.51.125] PHP Warning: Attempt to assign property of non-object in /var/www/itop/vendor/symfony/src/Symfony/Component/HttpFoundation/ParameterBag.php on line 34
[Sun Feb 12 17:09:30 2012] [error] [client 192.168.51.125] PHP Warning: Attempt to assign property of non-object in /var/www/itop/vendor/symfony/src/Symfony/Component/HttpFoundation/Request.php on line 124
[Sun Feb 12 17:09:30 2012] [error] [client 192.168.51.125] PHP Warning: Attempt to assign property of non-object in /var/www/itop/vendor/symfony/src/Symfony/Component/HttpFoundation/ParameterBag.php on line 34
[Sun Feb 12 17:09:30 2012] [error] [client 192.168.51.125] PHP Warning: Attempt to assign property of non-object in /var/www/itop/vendor/symfony/src/Symfony/Component/HttpFoundation/Request.php on line 125
[Sun Feb 12 17:09:30 2012] [error] [client 192.168.51.125] PHP Warning: Attempt to assign property of non-object in /var/www/itop/vendor/symfony/src/Symfony/Component/HttpFoundation/ParameterBag.php on line 34
[Sun Feb 12 17:09:30 2012] [error] [client 192.168.51.125] PHP Warning: Attempt to assign property of non-object in /var/www/itop/vendor/symfony/src/Symfony/Component/HttpFoundation/Request.php on line 126
[Sun Feb 12 17:09:30 2012] [error] [client 192.168.51.125] PHP Warning: Attempt to assign property of non-object in /var/www/itop/vendor/symfony/src/Symfony/Component/HttpFoundation/FileBag.php on line 48
[Sun Feb 12 17:09:30 2012] [error] [client 192.168.51.125] PHP Warning: Attempt to assign property of non-object in /var/www/itop/vendor/symfony/src/Symfony/Component/HttpFoundation/Request.php on line 127
[Sun Feb 12 17:09:30 2012] [error] [client 192.168.51.125] PHP Warning: Attempt to assign property of non-object in /var/www/itop/vendor/symfony/src/Symfony/Component/HttpFoundation/ParameterBag.php on line 34
[Sun Feb 12 17:09:30 2012] [error] [client 192.168.51.125] PHP Warning: Attempt to assign property of non-object in /var/www/itop/vendor/symfony/src/Symfony/Component/HttpFoundation/Request.php on line 128
[Sun Feb 12 17:09:30 2012] [error] [client 192.168.51.125] PHP Fatal error: Call to a member function getHeaders() on a non-object in /var/www/itop/vendor/symfony/src/Symfony/Component/HttpFoundation/Request.php on line 129
我们真的很难找出问题 其他人也遇到过此类问题吗?任何帮助将不胜感激。
We deployed our first Symfony2 website in production this week.
Strange things started to happen with it on server but we could not able reproduce the problem locally. We tested on other servers and caught the same errors too. If it helps we tried ubuntu ami on amazon ec2 and debian on other server. Also both apache2+mod_php and nginx+php-fpm, php version is 5.3.3. Symfony is 2.0.9.
Some requests just returns blank screen and in error logs appears following errors:
[Sun Feb 12 17:09:30 2012] [error] [client 192.168.51.125] PHP Warning: Attempt to assign property of non-object in /var/www/itop/vendor/symfony/src/Symfony/Component/ClassLoader/ApcUniversalClassLoader.php on line 80
[Sun Feb 12 17:09:30 2012] [error] [client 192.168.51.125] PHP Warning: Attempt to assign property of non-object in /var/www/itop/app/bootstrap.php.cache on line 1152
[Sun Feb 12 17:09:30 2012] [error] [client 192.168.51.125] PHP Warning: Attempt to assign property of non-object in /var/www/itop/app/bootstrap.php.cache on line 1146
[Sun Feb 12 17:09:30 2012] [error] [client 192.168.51.125] PHP Warning: Attempt to assign property of non-object in /var/www/itop/app/bootstrap.php.cache on line 464
[Sun Feb 12 17:09:30 2012] [error] [client 192.168.51.125] PHP Warning: Attempt to assign property of non-object in /var/www/itop/app/bootstrap.php.cache on line 465
[Sun Feb 12 17:09:30 2012] [error] [client 192.168.51.125] PHP Warning: Attempt to assign property of non-object in /var/www/itop/app/bootstrap.php.cache on line 466
[Sun Feb 12 17:09:30 2012] [error] [client 192.168.51.125] PHP Warning: Attempt to assign property of non-object in /var/www/itop/app/bootstrap.php.cache on line 666
[Sun Feb 12 17:09:30 2012] [error] [client 192.168.51.125] PHP Warning: Attempt to assign property of non-object in /var/www/itop/app/bootstrap.php.cache on line 467
[Sun Feb 12 17:09:30 2012] [error] [client 192.168.51.125] PHP Warning: Attempt to assign property of non-object in /var/www/itop/app/bootstrap.php.cache on line 468
[Sun Feb 12 17:09:30 2012] [error] [client 192.168.51.125] PHP Warning: Attempt to assign property of non-object in /var/www/itop/app/bootstrap.php.cache on line 469
[Sun Feb 12 17:09:30 2012] [error] [client 192.168.51.125] PHP Warning: Attempt to assign property of non-object in /var/www/itop/vendor/symfony/src/Symfony/Component/HttpFoundation/ParameterBag.php on line 34
[Sun Feb 12 17:09:30 2012] [error] [client 192.168.51.125] PHP Warning: Attempt to assign property of non-object in /var/www/itop/vendor/symfony/src/Symfony/Component/HttpFoundation/Request.php on line 123
[Sun Feb 12 17:09:30 2012] [error] [client 192.168.51.125] PHP Warning: Attempt to assign property of non-object in /var/www/itop/vendor/symfony/src/Symfony/Component/HttpFoundation/ParameterBag.php on line 34
[Sun Feb 12 17:09:30 2012] [error] [client 192.168.51.125] PHP Warning: Attempt to assign property of non-object in /var/www/itop/vendor/symfony/src/Symfony/Component/HttpFoundation/Request.php on line 124
[Sun Feb 12 17:09:30 2012] [error] [client 192.168.51.125] PHP Warning: Attempt to assign property of non-object in /var/www/itop/vendor/symfony/src/Symfony/Component/HttpFoundation/ParameterBag.php on line 34
[Sun Feb 12 17:09:30 2012] [error] [client 192.168.51.125] PHP Warning: Attempt to assign property of non-object in /var/www/itop/vendor/symfony/src/Symfony/Component/HttpFoundation/Request.php on line 125
[Sun Feb 12 17:09:30 2012] [error] [client 192.168.51.125] PHP Warning: Attempt to assign property of non-object in /var/www/itop/vendor/symfony/src/Symfony/Component/HttpFoundation/ParameterBag.php on line 34
[Sun Feb 12 17:09:30 2012] [error] [client 192.168.51.125] PHP Warning: Attempt to assign property of non-object in /var/www/itop/vendor/symfony/src/Symfony/Component/HttpFoundation/Request.php on line 126
[Sun Feb 12 17:09:30 2012] [error] [client 192.168.51.125] PHP Warning: Attempt to assign property of non-object in /var/www/itop/vendor/symfony/src/Symfony/Component/HttpFoundation/FileBag.php on line 48
[Sun Feb 12 17:09:30 2012] [error] [client 192.168.51.125] PHP Warning: Attempt to assign property of non-object in /var/www/itop/vendor/symfony/src/Symfony/Component/HttpFoundation/Request.php on line 127
[Sun Feb 12 17:09:30 2012] [error] [client 192.168.51.125] PHP Warning: Attempt to assign property of non-object in /var/www/itop/vendor/symfony/src/Symfony/Component/HttpFoundation/ParameterBag.php on line 34
[Sun Feb 12 17:09:30 2012] [error] [client 192.168.51.125] PHP Warning: Attempt to assign property of non-object in /var/www/itop/vendor/symfony/src/Symfony/Component/HttpFoundation/Request.php on line 128
[Sun Feb 12 17:09:30 2012] [error] [client 192.168.51.125] PHP Fatal error: Call to a member function getHeaders() on a non-object in /var/www/itop/vendor/symfony/src/Symfony/Component/HttpFoundation/Request.php on line 129
We are really stuck trying to find out the problem Has anybody else got this kind of problems? Any help would be appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
根据我的经验,当您遇到这样的奇怪错误时,特别是当您在无意义的地方看到随机的“非对象”问题时,问题始终是内存。从字面上看,正在创建一个对象,但随后该对象在内存中丢失,因此到下一行,它不再是一个对象。我只见过几次这种情况,但它总是与 APC 的问题有关。事实上,在我的上一份工作中,我们在升级到 PHP 5.3 后遇到了类似的问题 - 它在大多数情况下都可以工作,但 APC 最终会耗尽内存,我们会收到这些错误。当时(大约一年前),(通过谷歌搜索)似乎 PHP 和 APC 在某些情况下存在一些问题。我肯定会调查 APC - 我真的认为这是你的问题。具体来说,APC 不会刷新旧内存来为新事物腾出空间。
祝你好运!
In my experience, when you have strange errors like this, particularly when you see random "non-object" issues in non-sensical places, the issue is always memory. Quite literally, an object is being created, but then that object is lost in memory, so by the next line, it's no longer an object. I've seen this only a few times, but it has always been related to a problem with APC. In fact, at my last job, we had a similar issue after upgrading to PHP 5.3 - it would work most of the time, but then APC would eventually run out of memory and we would get these errors. At the time (about a year ago), it seemed (from googling) that there were some issues in some cases with PHP and APC. I would definitely look into APC - I really think it's your problem. Specifically, APC is not flushing its old memory to make room for new things.
Good luck!
好的,我想我们找到了解决这个问题的方法。当我们将服务器上的 php 升级到最新版本:5.3.10 时,奇怪的错误消失了。就是这么简单。可能是 php 5.3.3 的一些错误,我不知道。我们在变更日志中没有发现任何相关内容。
这个周末我们将用 freebsd 和 5.3.8 测试另一台机器。
感谢所有试图提供帮助的人。
Ok, I think we found the solution to this problem. Strange errors disappeared when we upgraded php on our server to the latest version: 5.3.10. It was that easy. May be it was some bugs of php 5.3.3, I don't know. And we haven't found anything related in changelogs.
This weekend we'll test another machine with freebsd and 5.3.8.
Thanks to everyone who tried to help.
您是否尝试过升级到 Symfony 2.0.10?
Have you tried upgrading to Symfony 2.0.10?