我们本周在生产中部署了我们的第一个Symfony2网站。
在服务器上开始发生奇怪的事情,但是我们无法在本地重现该问题。我们在其他服务器上进行了测试,也捕获了相同的错误。如果有帮助,我们在Amazon 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
我们真的很想找出问题所在,还有其他人遇到过此类问题吗?任何帮助,将不胜感激。
最佳答案
以我的经验,当您遇到类似这样的奇怪错误时,尤其是当您在无理的地方看到随机的“非对象”问题时,问题总是记忆。从字面上看,正在创建一个对象,但随后该对象在内存中丢失,因此到下一行,它不再是对象。我只看过几次,但这一直与APC的问题有关。实际上,在我的上一份工作中,升级到PHP 5.3后,我们遇到了类似的问题-大部分时间都可以使用,但是APC最终会耗尽内存,并且会出现这些错误。当时(大约一年前),(通过谷歌搜索)似乎在某些情况下PHP和APC存在一些问题。我一定会研究APC-我真的认为这是您的问题。具体来说,APC不会刷新其旧内存来为新事物腾出空间。
祝好运!
关于ubuntu - Symfony2生产失败,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/9249076/