1. 下载

Nginx的下载地址:http://www.nginx.org/

PHP的下载地址:http://www.php.NET/downloads.php

 win7 64  +  php-5.4.8-Win32-VC9-x86  +  nginx-1.2.4

2. Windows平台下的nginx、php的安装配置。

  • 2.1 解压下载的nginx和php的压缩包。
  • 2.2 修改nginx/conf/nginx.conf文件中对应的php配置部分,如下:
            # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000  
            #  
            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;  
                include        fastcgi.php.conf;  
            }  

 

特别需要注意的是:fastcgi_param这个参数默认的是$fastcgi_script_name;**最好改为$document_root$fastcgi_script_name;  我**在实际配置中出现了php找不到需要解析文件而返回404或者500错误的问题。所以最好是带上网站根目录的路径变量$document_root。

 

  • 2.3 运行nginx:

D:/www/nginx-0.7.61>start nginx.exe

以start的方式运行,nginx不需要一直占有cmd窗口,这样方便之后调试时,随时重载配置文件。

 

  • 2.4 运行php_cgi:

D:/www/php>php-cgi -b 127.0.0.1:9000

  • 2.5 测试是否安装成功

在nginx/html下面,新建一个phpinfo.php文件,写一个phpinfo的测试文件:

  1. <?php  
  2. phpinfo();  
  3. ?>  

尝试访问http://127.0.0.1:端口号/phpinfo.php,如果看到了php的相关信息,那么就说明配置成功了。

 如果有报报错,error: Call to undefined function mb_convert_encoding()

  如果有UTF-8问题, 1、添加文件 c:/php/ext/php-mbstrings.dll   2、在php.ini文件中取消extension=php_mbstring.dll的注释

 
posted on 2017-02-23 16:03  陈峰  阅读(179)  评论(0编辑  收藏  举报