Categories

Sunday, July 26, 2009

Successfully done installing nginx and php on windows

Environment:
  • July 26, 2009
  • Windows 7 7100 RC
  • nginx 0.8.6 for windows
  • php 5.3.0 no thread safe vc6 version
Steps:
  • unzip nginx packageto folder nginx-0.8.6
  • unzip php package to folder nginx-0.8.6\php-5.3.0-nts-vc6
  • edit file nginx-0.8.6\conf\nginx.conf, search and update following blocks:
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}

where html is the web root folder of nginx server locating at nginx-0.8.6\html,
and
$document_root and $fastcgi_script_name are two global variables defined in nginx-0.8.6\conf\fastcgi_params.

  • make a copy of nginx-0.8.6\php5.3.0-nts-vc6\php.ini-production and rename it to php.ini. Open it and edit the following blocks to be:
extension_dir = "ext"
  • open command promote and navigate to (yourpath)\nginx-0.8.6, run the command below:
php-5.3.0-nts-vc6\php-cgi.exe -b 127.0.0.1:9000

no echo should appear and the window stays idle.
  • open another command promote and navigate to (yourpath)\nginx-0.8.6, run the command below:
nginx.exe

again, no echo should appear and the window stays idle.
  • open a browser window and navigate to:
http://localhost:7777/(yourphpfile).php

=end of the tutorial=
================================
the following part is not for googlers, but some personal thoughts and feelings about the installation.

前段时间有听说过nginx,据说又小又强,但是一直没有时间研究一下.前天(周五)晚上刚好无事可做,于是决定在windows下试试,说不定可以取代Apache.后来果然发现有一个叫fast-cgi的东东,然后还有nginx+fast-cgi+php的组合,迁移到windows 之后再加上mysql,就成了一个WEMP,可以取代WAMP.这样一来不禁心潮澎湃,打完电话后开始研究.
一开始还是挺顺利的,但是PHP一直不行.弄到刚才才发现可能是php-cgi的路径问题,后来改变了extensions的位置,果然就可以了.
在没有连接的状态下,nginx默认开了两个process,php-cgi是一个,占用的资源加起来不到5M,感觉相当的不错.

No comments:

Post a Comment