windows nginx +php 配置

在windows下进行nginx +php的配置比较简单:

1、首先下载安装php,版本至少要在5.0以上(主要是要PHP版本支持FastCgi方式,包含有php-cgi.exe即可 ),修改php.ini配置文件

enable_dl = On
cgi.force_redirect = 1
cgi.fix_pathinfo=1
fastcgi.impersonate = 1
cgi.rfc2616_headers = 1

rror_reporting = E_ALL
display_errors = On
extension_dir = "C:\php\ext"
; 动态扩展,可以根据需要去掉 extension 前面的注释 ; 
; 如加载 PDO, MySQL
extension=php_pdo.dll
extension=php_pdo_mysql.dll

extension=php_gd2.dll

extension=php_mbstring.dll

extension=php_mysql.dll

 

extension=php_mysqli.dll

2、Nginx配置PHP是以FastCgi方式配置的

3、用文本编辑功能根据打开E:\nginx1.0\conf 目录下的nginx.conf,找到

 

 

        location / {

            root   html;

            index  index.html index.htm;

        }

修改为

 

 

        location / {

            root   D:/PHPWeb;

            index  index.php index.html index.htm;

        }

找到

 

# 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  /scripts$fastcgi_script_name;

        #    include        fastcgi_params;

        #}

修改为

 

# 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  D:/PHPWeb$fastcgi_script_name;

            include        fastcgi_params;

        }

4、启动fast-cgi

 找到php的安装目录,在控制台输入以下命令

f:/php/php-cgi.exe -b 127.0.0.1:9000 -c f:/php/php.ini

5、找到nginx的安装目录,启动nginx

或者建立bat文件启动fast-cgi和nginx,

首先下载RunHiddenConsole.exe,附件提供下载

建立start_nginx.bat,输入以下内容:

 

 

@echo off

echo Starting PHP FastCGI...

RunHiddenConsole f:/php/php-cgi.exe -b 127.0.0.1:9000 -c f:/php/php.ini

echo Starting nginx...

d:/nginx1.0/nginx.exe

其中 127.0.0.1:9000 一定要和nginx.conf里的 fastcgi_pass   127.0.0.1:9000;要完全一致,否则会出现错误

 

建立stop_nginx.bat,输入以下内容:

 

 

 

@echo off

echo Stopping nginx...

taskkill /F /IM nginx.exe > nul

echo Stopping PHP FastCGI...

taskkill /F /IM php-cgi.exe > nul

exit

 

在配置完成后,在D:/PHPWeb的目录下新建index.php文件,内容如下:

<?php

phpinfo();

?>

在ie地址栏里输入http://localhost/index.php,如果出现php的相关信息,则配置成功

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值