Nginx + php5-fpm doesn’t work properly. I see a white screen only

nginx

I've just installed nginx and php5-fpm and I want to test it on port 82. So I call http://mysite.com:82/test555.php and I see nothing. Just a white screen. No errors, no warnings, I don't see nothing at all 🙂 There are an error log of nginx and an error log of php5-fpm – but… There are no any errors. I don't undestand what's wrong. Please help me to find out it.

root@localhost:# echo "<?php phpinfo(); ?>" > /home/www/public_html/test555.php
root@localhost:# chmod 755 /home/www/public_html/test555.php
root@localhost:# cat /etc/nginx/sites-available/default
server {
        listen 82;
        root /home/www/public_html;
        index index.php index.html;

        server_name mysite.com;
        access_log /var/log/nginx/nginx-access.com.log;
        error_log /var/log/nginx/nginx-errors.com.log;

        location ~ \.php$ {
                fastcgi_pass unix:/var/run/php5-fpm.sock;
                # fastcgi_pass 127.0.0.1:9000;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME   $document_root$fastcgi_script_name;
                fastcgi_param QUERY_STRING              $query_string;
                fastcgi_param REMOTE_ADDR               $remote_addr;
        }
}

root@localhost:# /etc/init.d/nginx status
 * nginx is running

root@localhost:# /etc/init.d/php5-fpm status
 * php5-fpm is running

root@localhost:# ls -la /var/run/php5-fpm.sock
srw-rw-rw- 1 root root 0 Feb  3 01:14 /var/run/php5-fpm.sock

root@localhost:# cat /var/log/php5-fpm.log 
....
[03-Feb-2014 01:14:52] NOTICE: configuration file /etc/php5/fpm/php-fpm.conf test is successful
[03-Feb-2014 01:14:52] NOTICE: fpm is running, pid 19080
[03-Feb-2014 01:14:52] NOTICE: ready to handle connections

root@localhost:# cat /var/log/nginx/nginx-access.com.log
...ip... - - [03/Feb/2014:01:29:44 +0000] "GET /test555.php HTTP/1.1" 200 5 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:26.0) Gecko/20100101 Firefox/26.0"

root@localhost:# cat /var/log/nginx/nginx-errors.com.log

root@localhost:#

What can I do next to find out what's going on? I see it should work fine. PHP script returns me code=200 but I doesn't see the output. It never been called, because I tried to add file_put_contents there and it really never been called by nginx.

I use ubuntu 12.04 fully upgraded today.

Best Answer

This SO Q&A sounds like it might be your issue, titled: nginx showing blank PHP pages.

Your location stanza should look similar to this:

location ~ \.php$ {
    include /path/to/fastcgi_params;
    fastcgi_pass  127.0.0.1:9000;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME /path/to/www/dir$fastcgi_script_name;
}

You have to pay special attention to the path to the script you're referencing for fastcgi_param.

References

Related Question