nginx + php-cgi on window server 2008

php-cgi.php just hang and die on a very low load.

To fix this, use spawn-php

Install

ActivePython-2.7.2.5-win64-x64.msi
pywin32-217.win-amd64-py2.7.exe

Change nginx configuration

worker_processes 1;

events {
worker_connections 1024;
}

http {
include mime.types;
default_type application/octet-stream;

sendfile on;
keepalive_timeout 65;

upstream php_farm {
server 127.0.0.1:9000 weight=1;
server 127.0.0.1:9001 weight=1;
server 127.0.0.1:9002 weight=1;
server 127.0.0.1:9003 weight=1;
server 127.0.0.1:9004 weight=1;
server 127.0.0.1:9005 weight=1;
server 127.0.0.1:9006 weight=1;
server 127.0.0.1:9007 weight=1;
server 127.0.0.1:9008 weight=1;
server 127.0.0.1:9009 weight=1;
}

server {
listen 80;
server_name localhost;
location / {
root html;
index index.php index.html index.htm;
}

error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}

location ~ \.php$ {
root html;
fastcgi_pass php_farm;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME c:/nginx/html/$fastcgi_script_name;
include fastcgi_params;
}
}
}

change associated array to indexed array

sometimes i want to change this form of array

array('position'=> array('data1', 'data2'..)
'year' => array('year1', 'year2'..)
)

to this

array(0 => array('position'=> 'data1',
'year' => 'year1'),
1 => array('position' => 'data2',
'year' => 'year2')

here is how i do it.

function array_group($data)
{
$result = array();
foreach($data as $key=>$rows)
foreach($rows as $i=>$value)
$result[$i][$key] = $value;

return $result;
}