Nginx with php-fpm generating blank page

I struggled a long time trying to figure out why my nginz + php-fpm setup was not working. I could tell that the gateway was fine and I was getting a HTTP 200 OK response, but the output was blank and there were no illuminating entries in either the nginx or php-fpm logs.

After a ton of research, I found the hint that I needed here:

Essentially, I needed to set the SCRIPT_FILENAME param like so:

fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;

Php_fpm needs this so that it knows the path to the PHP file. You may need to set this param differently according to where you store your PHP files.

The default nginx setup I used includes a fastcgi_params file and a fastcgi.conf file. The fastcgi.conf file defines SCRIPT_FILENAME whereas the fastcgi_params does not. My guess is that the fastcgi.conf is not being used, which is why SCRIPT_FILENAME was not set.

  • avontz

    live saver =)

  • Pete

    Thanks a bunch!

  • Rodrigo Fonseca

    Thank you!

  • Fagner Sá de Souza

    Save my life

  • Pingback: Fix: Error opening wordpress and other php website after PHP upgrade | Cryptic Ideas

  • Rodrigo Ramos

    thank bro, u save my day!!

  • Yashodhan Talwar

    Amazing. Thank you!

  • Martie

    After upgrading my (before correct working) Ubuntu Linux server i got this problem too :)
    Amazing, just added the SCRIPT_FILENAME line, restarted the nginx service als all php pages working again.
    Thank you for sharing your knowledge. It saved my server.

  • moon

    I literally struggled with this for an entire day. Thank you so much! Wish I could give this post stars or something so that it returns as the first solution for any other frustrated googlers.

  • Thomas Beutel

    I’m glad it helped.

  • Thomas Beutel

    My pleasure, I’m glad it helped. Thank you for the offer of stars, that means a lot to me. If you have a blog you can link to this post or you can tweet this post. That would really help others find this.

  • Con Chim Nh?

    Hi ! Add that line to fastcgi_params file or a fastcgi.conf file ?

  • Manuel

    “$request_filename” is enough here, no need to build a path by hand :)

  • marketto

    Thank you, you saved my time)

  • bryanisimo

    Thanks, you save my life, this happends to me in a nginx update

  • Jan

    Thanks so much, this sure saved me from a serious headache!

  • Silver Moon

    thanks for this. had to do on Debian 8.1 + Nginx

  • Vasja Zupan

    thanks! saved me too :)

  • Roy Heeneman

    Thank you so much! You made my day!

  • Will

    Thanks that did the trick after upgrading from nginx 1.4 to 1.9.12

  • Pavel

    Thank you!
    Why this didnt set by default?

  • Igor Zvyagintsev

    Oh, thnx man! Three years after writing it is still useful

  • CreadevDotOrg

    Thanks, that is awesome :)