Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I am having a hard time trying to understand why my php page doesn't load. It always ends up in a 502 error page.

I'm on osx mountain lion with homebrew installed nginx and php-fpm with php 5.5.7

My php app loads properly on on nginx/php-fpm combo on all pages except one.

I was previously using apache2 and the app worked perfectly.

I managed to print the php variables on my script but found that php-fpm fails/dies just before the php execution goes to the view page of my app.

I have no idea how to rectify this issue and have been tearing my hair over this. Any input is appreciated.

The memory_limit in php.ini is set to 256M to even 512M but it has no effect.

Am I suppose mess around something with the php-fpm.conf? I really need some help!


worker_processes  4;
pid        /usr/local/var/run/nginx.pid;

error_log  /usr/local/etc/nginx/logs/error.log debug;

events {
    worker_connections  256;

http {
    include             mime.types;
    default_type        application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /usr/local/etc/nginx/logs/access.log  main;

    sendfile            on;

    keepalive_timeout   75;

    index index.html index.php;

    include /usr/local/etc/nginx/sites-enabled/*; 


location ~ \.php$ {
    try_files      $uri = 404;
    fastcgi_index  index.php;
    fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;

    fastcgi_buffer_size 64k;
    fastcgi_buffers 4 64k;

    include        fastcgi_params;


pm.max_children = 50
share|improve this question

closed as off-topic by Nathan C, Falcon Momot, Wesley, cole, womble Dec 23 '13 at 9:51

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions must be relevant to professional system administration. Server Fault is dedicated to professional system and network administrators. End user and enthusiast questions are off-topic (contact your system administrator or hire a professional to help you out). Please see the Help Center for more information." – Nathan C, Falcon Momot, Wesley, cole
If this question can be reworded to fit the rules in the help center, please edit the question.

please let me know how I clarify my problem before downvoting me. this is my first question on stack exchange. thanks. –  RyanYJL Dec 22 '13 at 6:04

1 Answer 1

up vote 0 down vote accepted

After much frustration. I managed to resolve my problem by checking my template view page.

I removed line by line and found that a helper in my script is 'causing' the error. The helper is huge and had various components but I managed to narrow it to the imagick php library.

The frustrating thing is that php logged no errors and the script just die sliently! no hint of a script error which led me to believe it was a memory problem with php-fpm.

I quadruple checked my php.ini for imagick and homebrew installs and uninstall reinstall unlink linked and still it made no sense why it still didn't work for php-fpm.

Note that my app had been running perfectly under apache with same php.ini and extensions.

The solution:

  1. setting catch_workers_output = yes in php-fpm.conf
  2. checking php-fpm.log and found that

    WARNING: [pool www] child 41818 said into stderr: "Assertion failed: (wand->signature == WandSignature), function MagickSetLastIterator, file wand/magick-wand.c, line 993."

    I googled for an idea of what is going and it gave me a hunch that there is some underlying conflict for imagick and gmagick extensions.

  3. I turned off gmagick extension and left imagick extension in my php.ini and volia the unknown 502 error for my page is gone!

Note that this conflict didn't exist in the apache setup. I don't understand why this is the case.

For anyone having a similar unknown problem with nginx/php-fpm 502 error. I suggest you check your php first, then turn on php-fpm error log and check it.

It might not a memory issue that is causing the 502.

I will post the link that gave me the hint later when I find it.


I can't find the resource that gave me the epiphany to drill it down to the conflict between the gmagick and imagick extension.

However, there are a few bug reports which validates the issue that I had experienced.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.