One of the great advantages of PHP5 's CGI approach is the built-in fastcgi support, which simply indicates that the bound address and port parameters can be run in fastcgi manner, as follows:
Php-cgi-b 127.0.0.1:9000
Configuring the Nginx PHP FastCGI
Save the following as a fastcgi_params file, saved under/usr/local/nginx/conf (Ubuntu can be saved under/etc/nginx), and he sets the basic environment variables for our fastcgi module:
#Fastcgi_paramsFastcgi_param Gateway_interface cgi/1.1; Fastcgi_param server_software nginx;fastcgi_param query_string $query _string;fastcgi_param REQUEST_METHOD $request _method;fastcgi_param content_type $content _type;fastcgi_param content_length $content _length;fas Tcgi_param script_filename $document _root$fastcgi_script_name;fastcgi_param script_name $fastcgi _script_name;f Astcgi_param Request_uri $request _uri;fastcgi_param document_uri $document _uri;fastcgi_param document_root $document _root;fastcgi_param server_protocol $server _protocol;fastcgi_param remote_addr $remote _addr;fas Tcgi_param remote_port $remote _port;fastcgi_param server_addr $server _addr;fastcgi_param server_port $server _port;fastcgi_param server_name $server _name;#PHP only, required if PHP is built with--enable-force-cgi-redirectFastcgi_param Redirect_status 200;
Pay particular attention to the "Fastcgi_script_name" line, where php-cgi specifically needs this information to determine the location of the PHP file.
In addition, you need to open the Cgi.fix_pathinfo option in the php-cgi configuration file (Ubuntu on this profile located in/etc/php5/cgi/php.ini):
Cgi.fix_pathinfo=1;
This allows the php-cgi to use the script_filename variable normally.
Next in the Nginx configuration for PHP files configured to use the FASTCGI process to execute:
Server { index index.php; Root /usr/local/nginx/html; ~. *. php$ { /usr/local/nginx/conf/fastcgi_params; # Please set it according to the path you saved fastcgi_index index.php; Fastcgi_pass # Please configure according to the address and port of your fastcgi binding }}
How PHP works in Nginx and Apache servers