原文:
http://hi.baidu.com/xchinux/item/b3bb8d394db012f62784f4871. 下载nginx-1.5.6
http://nginx.org/download/nginx-1.5.6.zip2. 下载
PHP 5.5.4,因为要以FastCGI方式运行,所以下载NTS(Not Thread Safe)版本
http://windows.php.net/downloads/releases/php-5.5.4-nts-Win32-VC11-x86.zip 上面要记住,如果系统中
没有安装MSVC2012运行库,需要先
安装上
3. 下载RunHiddenConsole,这个是用来写bat脚本并隐藏控制台
窗口的
http://redmine.lighttpd.net/attachments/660/RunHiddenConsole.zip4. 假设将PHP解压到C:/php目录下,则拷贝php.ini-production文件,重命名为php.ini,然后用配事本打开这个
文件,修改关键配置,将cgi.fix_pathinfo=1前面的注释符(分号)去掉
5. 修改
nginx的配置,假设nginx解压到C:/nginx目录下,假设网站根
目录为C:/html,则修改conf/nginx.conf文件,找到下面这段内容:
- location / {
- root html;
- index index.html index.htm;
- }
修改为下面内容:
- location / {
- root C:/html;
- index index.html index.htm index.php;
- }
然后再找到下面这段内容:
- #location ~ \.php$ {
- # root html;
- # fastcgi_pass 127.0.0.1:9000;
- # fastcgi_index index.php;
- # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
- # include fastcgi_params;
- #}
将其注释去掉并修改完下面内容:
- location ~ \.php$ {
- root C:/html;
- fastcgi_pass 127.0.0.1:9000;
- fastcgi_index index.php;
- fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
- include fastcgi_params;
- }
6. 将RunHiddenConsole.zip解压开,里面是一个RunHiddenConsole.exe,将其放到C:/nginx目录下,然后写下面两个文件:
start_nginx.bat
- @echooff
- REM Windows下无效
- REM set PHP_FCGI_CHILDREN=5
- REM 每个进程处理的最大请求数,或设置为Windows环境变量
- set PHP_FCGI_MAX_REQUESTS=1000
- echo Starting PHP FastCGI...
- RunHiddenConsole C:/php/php-cgi.exe -b 127.0.0.1:9000 -c C:/php
- echo Starting nginx...
- RunHiddenConsole C:/nginx/nginx.exe -p C:/nginx
stop_nginx.bat
- @echooff
- echo Stopping nginx...
- taskkill /F /IM nginx.exe > nul
- echo Stopping PHP FastCGI...
- taskkill /F /IM php-cgi.exe > nul
- exit
OK,至此配置完毕,启动时点击或执行start_nginx.bat即可,停止时执行stop_nginx.bat即可。