1.首先,您需要准备应用程序包。nginx:nginx-rtmp-win32ornginx/Windows-1.0.4(无rtmp模块)php:php-5.2.16-nts-Win32-VC6-x86.zip(nginx下的php运行在FastCGI模式,所以我们下载非线程安全的php包即nts)RunHiddenConsole:RunHiddenConsole.zip(用于cmd非阻塞运行进程)2.安装配置。1)PHP安装配置。直接将下载的php包解压,进入D盘的wnmp目录(D:wnmp),这里将解压后的文件夹重命名为php5。进入文件夹修改php.ini-recommended文件为php.ini,用Editplus或Notepad++打开。找到扩展目录(去掉注释);extension_dir="ext"mysql扩展(去掉注释);extension=php_mysql.dll;extension=php_mysqli.dll前面指定php的ext路径后,将需要的扩展包放在对应的“;”前面即可被删除,就是这样。在这里打开php_mysql.dll和php_mysqli.dll,让php支持mysql。当然,别忘了还有很重要的一步,将php5目录下的libmysql.dll文件复制到C:Windows目录下,或者在系统变量中指定路径。当然我这里选择了更方便的方法^_^。至此,php已经可以支持mysql了。接下来我们来配置php,让php可以和nginx结合起来。查找(去掉注释);cgi.fix_pathinfo=1这一步很重要,这里是php的CGI设置。2)nginx的安装和配置。将下载的nginx-1.0.4包解压到D盘wnmp目录下,重命名为nginx。接下来,让我们配置nginx以与php一起工作。进入nginx的conf目录,打开nginx配置文件nginx.conf,找到worker_processes1;error_loglogs/error.logdebug;events{worker_connections1024;}rtmp{server{listen1936;applicationlive{liveon;pullrtmp://live.hkstv.hk。lxdns.com/live/hkslive=1name=1;}}}http{access_loglogs/access.http.log;server_tokensoff;default_typeapplication/octet-stream;client_max_body_size10G;sendfileon;创建当前目录other.confserver{listen7777;server_namelive_stream;rootwww;index.php;location/{if(!-e$request_filename){rewrite^(.*)$/index.php?s=/$1last;#rewritemode#rewrite^(.*)$/index.php/$1最后;#pathinfomode}}location~\.php${fastcgi_hide_headerX-Powered-By;fastcgi_pass127.0.0.1:9000;fastcgi_split_path_info^(.+\.php)(.*)$;fastcgi_paramPATH_INFO$fastcgi_path_info;fastcgi_paramPATH_TRANSLATED$document_root$fastcgi_path_info;fastcgi_paramSCRIPT_FILENAME$document_root$fastcgi_script_name;includefastcgi_params;fastcgi_connect_timeout300;fastcgi_send_timeout300;fastcgi_read_timeout300;}}Save配置文件就是这样。nginx+php的环境已经初步配置好了,我们运行看看。我们可以输入命令X:\wnp\php\php-cgi.exe-b127.0.0.1:900-cX:\wnp\php\php.ini双击nginx.exe完成!!!3.批处理脚本控制开关Server1.start.cmd@echooffREMWindows下无效REMsetPHP_FCGI_CHILDREN=5REM每个进程处理的最大请求数,或者设置到Windows环境变量setPHP_FCGI_MAX_REQUESTS=1000echoStartingPHPFastCGI...RunHiddenConsoleD:/wnmp/php5/php-cgi.exe-b127.0.0.1:9000-cD:/wnmp/php5/php.iniechoStartingnginx...RunHiddenConsoleD:/wnmp/nginx/nginx.exe-pD:/wnmp/nginx2.end.cmd@echooffechoStoppingnginx。..taskkill/F/IMnginx.exe>nulechoStoppingPHPFastCGI...taskkill/F/IMphp-cgi.exe>nulexit4。填坑php文件无法接收参数,$_GET,$_POST,$_REQUEST为空。解决方法:在other.conf文件中,“includefast_params”nginx官网示例位置~\.php${fastcgi_hide_headerX-Powered-By;fastcgi_pass127.0.0.1:9000;fastcgi_split_path_info^(.+\.php)(.*)$;fastcgi_paramPATH_INFO$fastcgi_path_info;fastcgi_paramPATH_TRANSLATED$document_root$fastcgi_path_info;fastcgi_paramSCRIPT_FILENAME$document_root$fastcgi_script_name;includefastcgi_params;fastcgi_connect_timeout300;fastcgi_send_timeout300;fastcgi_read_timeout300;}5.参考1.windows下配置nginx+php环境
