Windows 下快速配置 nginx + php 5.3

一、下载最新的稳定的 nginx 的版本:http://nginx.org/

解压到 D:\nginx,修改配置文件 D:\nginx\conf\nginx.conf,找到:

#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           html;
    fastcgi_pass   127.0.0.1:9000;
    fastcgi_index  index.php;
    fastcgi_param  SCRIPT_FILENAME  html$fastcgi_script_name;
    include        fastcgi_params;
}

二、下载 php 5.3 VC6 x86 Non Thread Safe:http://windows.php.net/download

解压到 D:\nginx\php,复制 php.ini-developmentphp.ini,并修改以下几处:

enable_dl = On
cgi.force_redirect = 0
cgi.fix_pathinfo = 1
fastcgi.impersonate = 1
date.timezone = "Asia/Shanghai"

三、配置启动方式:

新建 start_nginx.vbs,内容如下:

Set wscriptObj = CreateObject("Wscript.Shell")
wscriptObj.run "D:\nginx\nginx.exe", 0
wscriptObj.run "D:\nginx\php\php-cgi.exe -b 127.0.0.1:9000 -c D:\nginx\php\php.ini", 0

新建 stop_nginx.vbs,内容如下:

Set wscriptObj = createobject("Wscript.Shell")
wscriptObj.run "taskkill /F /IM nginx.exe", 0
wscriptObj.run "taskkill /F /IM php-cgi.exe", 0

或 新建 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

运行 start_nginx.vbs,在 D:\nginx\html 新建 info.php
打开浏览器访问 http://localhost/info.php,搞定收工!

留下评论

电子邮件地址不会被公开。 必填项已用*标注