Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I've just installed nginx and php5-fpm and I wanna 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.

share|improve this question
    
What are the contents of /var/log/nginx/nginx-errors.com.log? –  samiam Feb 3 at 2:07
    
See if this is relevant: bbs.archlinux.org/viewtopic.php?id=101750 –  Ketan Feb 3 at 2:07

2 Answers 2

up vote 4 down vote accepted

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

share|improve this answer
    
Yeah, that was my fault. I've added a line: "include fastcgi_params;" to location and now it works! –  JavaRunner Feb 3 at 2:49
    
@JavaRunner - glad to hear your issue's been resolved! –  slm Feb 3 at 2:57

This might be useful to others facing this problem,

You also can add into your nginx conf file fastcgi_params the following line, so you don't need to specify path to the variable SCRIPT_FILENAME

fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;

This is very handy specially when you have many virtual hosts.

share|improve this answer
    
thank you, this is much better than including a different path all the time –  krdx Aug 21 at 18:58

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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