tango bango tango bango - 1 year ago 227
PHP Question

php5.6-fpm with nginx on ubuntu 16.04 receiving no data

I have just installed ubuntu 16.04 and php5.6-fpm and nginx.
nginx server block is as follows:

server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;

root /usr/share/nginx/html;
index index.php index.html index.htm;

location ^~ /.git/{
deny all;

location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/run/php/php5.6-fpm.socket;
fastcgi_index index.php;
include /etc/nginx/fastcgi_params;
fastcgi_intercept_errors on;

location / {
try_files $uri $uri/ =404;

Now when i take localhost, it shows me nothing. No data received. Response code 200.

If i try to access any static file. It works fine. Eg: localhost/xyz.png will show the image.
But no data is received when trying to run a php script.
It doesn't matter if script file is present or not. Response for a php script is constant. i.e no data but 200 ok response.

Please help me out. Thanks in advance.

Answer Source

You forgot to add SCRIPT_FILENAME:

location ~ \.php$ {
    # add this:
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download