Query regarding Nginx working with FastCGI

Rishab Jain rishab.jain at sourcefuse.com
Mon Jul 11 13:21:51 MSD 2011


Hi guys,

I'm facing an issue and was wondering if anybody could help me with this.

I have an Ubuntu server, and I have installed all the softwares required 
using apt-get. Now, I have installed Nginx using the same mechanism as 
well. I want to use the Nginx for serving php scripts from the browser 
too. So therefore, after going through the web, I learn't that we need 
FastCGI to be installed.

Now, as soon as the installation was complete, I restarted Nginx server 
and tried accessing the php file. Instead of executing the script, it 
was actually showing me  the php code on the browser. It wasn't untill I 
executed the following command:
  /usr/bin/spawn-fcgi -a 127.0.0.1 -p 9090 -u www-data -g www-data -f 
/usr/bin/php5-cgi -P /var/run/fastcgi-php.pid

As soon as I executed this command, and, restarted Nginx again, I was 
able to execute the PHP script.

Now, my issue is since fastcgi is being binded by a port, it means that 
there's a kind of a daemon running. So, going forward, if I make this 
server live, and, by any chance the fastcgi daemon crashes, the ubuntu 
will start throwing up my php code to the users (which is obviously 
never desired).

I actually want to know a way we can prevent the php code from getting 
displayed to the user, irrespective of whether the fastcgi is running or 
not.

regards,
Rishab



More information about the nginx mailing list