开发者

Premature end of script headers: php5 Symfony produces internal server error 500

开发者 https://www.devze.com 2023-01-13 19:09 出处:网络
I am running into an issue that is leaving me in a dead end so in turn, I turn to you!Recently a Symfony app has been going down rendering an internal apache error -500.After deleting the Symfony cach

I am running into an issue that is leaving me in a dead end so in turn, I turn to you! Recently a Symfony app has been going down rendering an internal apache error -500. After deleting the Symfony cache the site comes back up. Upon some further investigating I have found the error of "Premature end of script headers: php5". The site has not produced any errors like this in over 1year and we have not made any changes to this site and this has been happening regularly(once a week). The following is from the log files.

[Sat Aug 28 06:20:30 2010] [error] [client 206.131.184.1] Premature end of script headers: php5

This email was also sent recently from MT, possibly related that I feel may directly relate to the issue.

It has come to our attention that your service ----.com, has been generating an unusually large number of file system locks on the cluster which hosts your account. Websites or scripts which utilize NFS file locking incorrectly can often generate this error, which inordinately affects the performance of the cluster for other customers. This is a violation of our AUP which c开发者_开发技巧an be found at 'http://mediatemple.net/company/legal/aup_general.php'.

We tracked the file locking issue to the following file which is being locked repeatedly:

/domains/----.com/symfony/cache/frontend/prod/config/routing/symfony.routing.configuration.cache /domains/----.com/symfony/cache/frontend/prod/config/routing/symfony.routing.data.cache

We recommend you immediately disable file locking for your scripts if the option is available (often located in the configuration section of the script); or use a different script which does not utilize file locking. Any future locking abuse by this script may result in the suspension of traffic to this domain to prevent the locking from affecting other customers.

If you have any questions regarding this file locking issue, or are not sure where to begin with disabling file locking, please respond to this ticket for further assistance.


It only occurs if you are browsing with Google Chrome and if an Exception is thrown. There where some changes in Monolog, they enabled "chromephp".

In your config_dev.yml:

monolog:
handlers:
    main:
        type:  stream
        path:  %kernel.logs_dir%/%kernel.environment%.log
        level: debug
    firephp:
        type:  firephp
        level: info
    chromephp:
        type:  chromephp
        level: info

Remove the whole chromephp block and everythings fine.


I think it's safe for you to disable Symfony's cache locking for reads in lib/cache/sfFileCache.class.php in method read(). Symfony takes a share lock when reading. The lock is not necessary because Symfony uses a temporal file and rename when writing. Also, in lib/log/sfFileLogger.class.php the lock in doLog() method is not necessary, since the write is atomic (single fwrite() call), and the file is opened in append mode.

I haven't tested how these changes would affect Symfony.

"Premature end of script headers" is not a PHP error message. The web server is issuing this message when the backend (PHP in this case) does not send headers. This is most likely because it dies before it's able to do anything. You should locate PHP error log and see the real error message. However, note that Symfony uses a lot of @ for error suppression in function calls so you may not find anything.


Recently I encountered similar issue. Replacing file caching with APC solved my problems completely. I needed to replace sfFileCache for view_cache, i18n cache and routing.

If APC is not available on your server than you can easily use any other popular accelerator instead.

How to use APC with symfony: http://www.zalas.eu/symfony-meets-apc-alternative-php-cache

0

精彩评论

暂无评论...
验证码 换一张
取 消