2

I'm running php-fpm on nginx

I have my php.ini values set as follows

upload_max_filesize = 100M
post_max_size = 128M
max_execution_time = 180

I have also set my client_max_body_size to 4G. When I try small uploads they work, but when I try a big upload of say 35M I get a 502 and when I look through the logs I see ,

upstream sent unexpected FastCGI record: 3 while reading response header from upstream

Any ideas? I've tried the nginx threads but they don't really help.

Thanks in advance

ryan
  • 125
  • 2
  • 6
  • You need to check the PHP error logs. – Michael Hampton Oct 23 '12 at 00:51
  • @MichaelHampton I checked my logs and though I have all ini parameters related to logs turned on, I don't see any errors in my php-fpm.log file. Can you tell me what I'm missing? – ryan Oct 23 '12 at 01:08
  • that's probably not where errors are logged. Check your `php.ini` to see if you even have logging enabled. – Michael Hampton Oct 23 '12 at 01:09
  • @MichaelHampton, `log_errors = On` and `error_log = /var/log/php.log` EDIT: php-fpm logs are also turned on and I find this on that " `WARNING: [pool www] child 920 said into stderr: "NOTICE: PHP message: PHP Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 39277825 bytes) in Unknown on line 0" ` No error logs in php.log – ryan Oct 23 '12 at 01:18
  • @MichaelHampton, I was trying a file of size 35M and so I'd set the memory_limit to 64M. Looks like irrespective of what the actual uplaod is, the memory_limit needs to be higher than max_upload_filesize. TIL. Thanks! – ryan Oct 23 '12 at 01:29
  • I've made a full answer out of it so that you can accept it, which marks the question as resolved. – Michael Hampton Oct 23 '12 at 01:34

1 Answers1

2

First step: ensure you have error logging enabled in php.ini and check the log entries.

From your log entry:

WARNING: [pool www] child 920 said into stderr: "NOTICE: PHP message: PHP Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 39277825 bytes) in Unknown on line 0"

It appears PHP has run out of memory processing the uploaded file. You will need to increase the memory_limit parameter. Further information on upload tuning can be found at the PHP web site.

Michael Hampton
  • 244,070
  • 43
  • 506
  • 972