0

I have a php script. I am using nginx and spawn-fcgi.

spawn-fcgi -n -s /tmp/nginx9010.socket -u www-data -g www-data -f /usr/bin/php5-cgi -C 6

How can I test from the command line that spawn-fcgi is working with the script?

e.g. I have a script in /home/ubuntu/test.php

I am having issues with nginx and executing a php script. It prompts for a download.

I have #!/usr/bin/php in the file and did a chmod a+x as well.

Thanks

Smar
  • 8,109
  • 3
  • 36
  • 48
Tampa
  • 75,446
  • 119
  • 278
  • 425

3 Answers3

1
  • For testing a FastCGI backend you could try to create a CGI environment and use cgi-fcgi to connect to the backend
  • You could attach with strace to see what the backend does (for example whether it even receives a request from the web server); attach with -ff to the master process to see syscalls on all workers
  • php5-cgi in FastCGI mode doesn't need a shebang line nor +x on the files - it doesn't use the kernel to execute them, it just loads them as simple files
  • Firefox (and probably other browsers too) often cache the mime type, so you will see a download prompt even after you fixed the problem. Use curl for testing!
Stefan
  • 5,304
  • 2
  • 25
  • 44
0

nginx won't serve the file it passes it to php, nginx only serves static files, So if it is downloading the php file you might need to check that your are sending php files to the correct place, are you using an IP and PORT in the php location block in the config file ?

Only a guess of the top of my head whilst on the train home.

Oliver Bayes-Shelton
  • 6,135
  • 11
  • 52
  • 88
0

FWIW, problems like that nginx offers the file to be downloaded are due Nginx serving the files itself without sending them to fastcgi backend, often because of try_files or wrong location {} block matching to the uri.

Smar
  • 8,109
  • 3
  • 36
  • 48