1、下载:nginx:http://nginx.org/en/download.html
php:http://windows.php.net/download/
2、解压:NGINX和PHP到你自己安装位置。NGINX目录:D:\Program Files (x86)\nginx-1.9.4PHP目录D:\Program Files (x86)\php
3、修改nginx配置文件conf/nginx.conf。
1、修改默认首页、指定php文件目录(D:/php/rs)
location / {
root D:/php/rs;
index index.html index.htm index.php;
}
主要是添加index.php
2、指定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 /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
先将前面的“#”去掉,同样将root html;改为root C:/wnmp/nginx-1.5.8/html;。再把“/scripts”改为“$document_root”,这里的“$document_ro;.lot”就是指前面“root”所指的站点路径,这是改完后的:
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root C:/wnmp/nginx-1.5.8/html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
# include fastcgi_params;
#}
4、php的配置:
1、修改
D:\Program Files (x86)\php\php.ini,打开php常用模块
D:\Program Files (x86)\php下修改php.ini-development文件,将文件名修改为php.ini,打开php配置文件php.ini,保存即可。
搜索“extension_dir”,找到: e;xtension_dir = "ext" 先去前面的分号再改为 extension_dir = "D:\Program Files (x86)\php\ext"
搜索“date.timezone”,找到:;date.timezone = 先去前面的分号再改为 date.timezone = Asia/Shanghai
搜索“enable_dl”,找到:enable_dl = Off 改为 enable_dl = On
搜索“cgi.force_redirect” ;cgi.force_redirect = 1 先去前面的分号再改为 cgi.force_redirect = 0
搜索“fastcgi.impersonate”,找到: ;fastcgi.impersonate = 1 去掉前面的分号
搜索“cgi.rfc2616_headers”,找到:;cgi.rfc2616_headers = 0 先去前面的分号再改为 cgi.rfc2616_headers = 1
搜索“php_mysql”,找到:”extension=php_mysql.dll和extension=php_mysqli.dll 去掉前面的“;”extension=php_mysql.dll和extension=php_mysqli.dll (支持MYSQL数据库)
2、启动php
cmd:
D:\Program Files (x86)\php>php-cgi.exe -b 127.0.0.1:9000-c php.ini
注意可能会出现msvcp110.dll找不到指定模块的情况。
最简单的办法是按照“百度电脑专家 ”可以修复这个问题:http://zhuanjia.baidu.com/detail?pid=1075&src=1#top