Skip to content

Instantly share code, notes, and snippets.

@antonioribeiro
Last active September 13, 2021 19:17
Show Gist options
  • Star 12 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save antonioribeiro/24a19f22cffd0beaa7e3 to your computer and use it in GitHub Desktop.
Save antonioribeiro/24a19f22cffd0beaa7e3 to your computer and use it in GitHub Desktop.
The Laravel Forge, NGINX, PHP-FPM & A Blank Page Debugging Tale

After an apt-get upgrade on my Forge box, both php and nginx got upgraded, and while browsing my sites, PHP FPM was being hit by nginx, but it returned nothing, zilch, nada.

Nothing on laravel.log.

Something in the nginx log:

10.10.10.10 - - [23/Sep/2014:11:52:09 -0300] "GET / HTTP/1.1" 200 31 "-" "Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.120 Safari/537.36"

Enabling xdebug.auto_trace, in /etc/php5/fpm/php.in, gave me

TRACE START [2014-09-23 14:52:09]
    0.0000      15456
TRACE END   [2014-09-23 14:52:09]

Enabling /status in /etc/php5/fpm/pool.d/www.conf:

pm.status_path = /status

And adding this location block to my site:

location ~ ^/(status|ping)$ {
   access_log off;
   allow 127.0.0.1;
   allow 186.228.132.40;
   deny all;
   include fastcgi_params;
   fastcgi_pass unix:/var/run/php5-fpm.sock;
}

I still got nothing from mysite.com/status. So I installed cgi-fcgi, a nice and handy tool:

sudo apt-get --yes install libfcgi0ldbl

Ran it directly to the site source

SCRIPT_NAME=/ SCRIPT_FILENAME=~/mysite.com/public/index.php QUERY_STRING= REQUEST_METHOD=GET cgi-fcgi -bind -connect /var/run/php5-fpm.sock

BANG! The site login page script exploded in my terminal. So I did the same with mysite.com/status:

SCRIPT_NAME=/status SCRIPT_FILENAME=/status QUERY_STRING= REQUEST_METHOD=GET cgi-fcgi -bind -connect /var/run/php5-fpm.sock

And it looked like PHP FPM was really working fine:

pool:                 www
process manager:      dynamic
start time:           23/Sep/2014:11:42:26 -0300
start since:          1230
accepted conn:        8
listen queue:         0
max listen queue:     0
listen queue len:     0
idle processes:       1
active processes:     1
total processes:      2
max active processes: 1
max children reached: 0
slow requests:        0

Xdebug created a huge file too.

Being sure the problem was in NGINX, I googled "nginx 1.6.2 php fpm" and found the fix, adding this line to my nginx site conf solved it:

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
@ielijose
Copy link

Found for me, thanks!

@dvlpp
Copy link

dvlpp commented Jan 1, 2015

Thanks a lot!

@atrull
Copy link

atrull commented Jun 19, 2015

You sir, win the internet.

@Bersam
Copy link

Bersam commented Jul 1, 2015

ty, :)

@zefman
Copy link

zefman commented Aug 15, 2015

Saviour!

@karmux
Copy link

karmux commented Aug 17, 2015

Thanks!

@punkeel
Copy link

punkeel commented Aug 24, 2015

Thanks, worked for me!

@davidhoeck
Copy link

Thanks man!

@hotrush
Copy link

hotrush commented Dec 20, 2018

Oh god, saved my evening)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment