您的位置:首页 > 运维架构 > Nginx

windows 下配置php+Nginx

2012-10-22 20:40 288 查看
折腾了一下午,终于搞定了windons下nginx下跑通了php。其实这个简单配置并不难,可是由于参考了网上的各种资料,可是很多不全,或者某些命令不正确导致花了这么长时间。所以我贴出我的经验。我的配置是:nginx-0.8.16+php5.2.171.首先将nginx和php都解压到D:/wnmp下2.配置PHP1),将php.ini-recommened,该为php.ini.打开php.ini设置:
cgi.fix_pathinfo = 1, cgi.force_redirect = 1,fastcgi.logging = 1,cgi.rfc2616_headers = 1,
2)将下面的注释去掉
;extension=php_mysql.dll
;extension=php_mysqli.dll
3).改变extension_dir,我的改为了extension_dir = "D:/wnmp/php5/ext"
4).将php.ini放到c:/window 下面,将php5ts.dll,libmysql.dll放到c:/window/system32 下面
3.配置nginx下面的nginx.conf
location / {
root   html;      #这里是站点的根目录
index  index.html index.htm;
}
将root  html;改为root   D:/wnmp/www;
# 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           D:/wnmp/www;
fastcgi_pass   127.0.0.1:9000;
fastcgi_index  index.php;
fastcgi_param  SCRIPT_FILENAME  D:/wnmp/www$fastcgi_script_name;
include        fastcgi_params;
}
4.保存配置文件,就可以了。
  nginx+php的环境就初步配置好了,来跑跑看。我们可以输入命令
5.启动nginx ,cmd 到nginx目录下,start nginx。
6.看到任务管理器有下面标红进程,就成功了。

                                            
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: