1

I have installed nginx, php-fpm and php56 on OS X EL CAPITAN. I used ps command to check whether nginx and fpm is running or not.

I have added the below code block to server block in nginX:

location ~ \.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } 

nginX listen on 8080 and fpm on 9000. I used lsof command to check that:

php-fpm 22903 root 0u IPv4 0x5a9bc9209264e227 0t0 TCP 127.0.0.1:9000 (LISTEN) php-fpm 22904 fc 0u IPv4 0x5a9bc9209264e227 0t0 TCP 127.0.0.1:9000 (LISTEN) nginx 22931 fc 6u IPv4 0x5a9bc9208c304cc7 0t0 TCP *:8080 (LISTEN) nginx 22932 fc 6u IPv4 0x5a9bc9208c304cc7 0t0 TCP *:8080 (LISTEN) 

Any clue about the issue why nginx downloads php files rather than interpreting them?

EDIT1:
Full nginX configuration:

http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; server { listen 8080; server_name localhost; location / { root html; index index.html index.htm; } location ~ \.php$ { root /usr/local/var/www/; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; include fastcgi_params; } } include servers/*; 

The URL I have fetched is: http://localhost:8080/info.php

Does anyone has any clue about this issue? I went on every question in stackoverflow with no success:

http://serverfault.com/questions/563285/nginx-with-php-fpm-downloading-php-files-rather-than-executing-them-on-mac-os-x?rq=1 http://serverfault.com/questions/412079/nginx-php-fpm-php-file-not-found-cant-figure-out-why?rq=1 
2
  • Please show your full configuration and what is the exact URL you are fetching when PHP file is downloaded. Commented Oct 7, 2016 at 19:07
  • @TeroKilkanen I have added the nginX full configuration file in the EDIT section, please have a look. Commented Oct 7, 2016 at 19:47

1 Answer 1

0

I've just changed the below line:

fastcgi_param SCRIPT_FILENAME $scripts$fastcgi_script_name; 

TO:

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 

It works now.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.