1、需要工具:

下载ngnix  网址:http://nginx.org/

下载:RunHiddenConsole

第二步 将下载文件解压后,将RunHiddenConsole拷贝到ngnix目录与php所在目录

修改conf目录下ngnix.conf,使其支持php

 site:

 server {
listen ; #端口
server_name example.org www.example.org; #域名
root e:/www; location / {
index index.html index.php;
} location ~* \.(gif|jpg|png)$ {
expires 30d; #缓存图片文件
}
#支持php
location ~ \.php$ {
fastcgi_pass 127.0.0.1:;
fastcgi_param SCRIPT_FILENAME
e:/www$fastcgi_script_name;
include fastcgi_params;
}
}

另外可以把虚拟主机单独出来

在ngnix.conf文件中加入如下代码

http{

#其它代码

include vhost/*.conf; #加载vhost目录下的虚拟主机配置文件 

}

可以在conf文件夹中新建一个vhost文件夹,在此目录下建立新文件自定义文件名,扩展名为conf即可,在文件中加入如下代码

 server {
listen 80;
server_name www.szs.com; #charset koi8-r; #access_log logs/host.access.log main; location / {
root E:/20nc;
index index.php index.html index.htm;
} #error_page 404 /404.html; # redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
} # proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
#root D:/wamp/www;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME E:/20nc$fastcgi_script_name;
include fastcgi_params;
}
location ~* \.(gif|jpg|png)$ {
expires 30d;
} # deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
location ~ /\.ht {
deny all;
}
}

  

第三步:配置php.ini文件使其支持cgi

;cgi.force_redirect = 1,删除前面的分号:cgi.force_redirect = 1

;cgi.fix_pathinfo=1,删除前面的分号:cgi.fix_pathinfo=1

;cgi.rfc2616_headers = 0,删除前面的分号:cgi.rfc2616_headers = 1

第四步:制作启动和关闭ngnix文件

注意:路径请自行更改

start.bat

@echo off
echo start_nginx.bat
  echo Starting PHP FastCGI...
cd D:/bin/php/php5.5.12
d:
  RunHiddenConsole php-cgi.exe -b 127.0.0.1:9000 -c php.ini
  echo Starting nginx...
cd C:/nginx
c:
  RunHiddenConsole nginx.exe
  Exit exit.bat @echo off
  echo stop_nginx.bat
  echo Stopping nginx...
  taskkill /F /IM nginx.exe > nul
  echo Stopping PHP FastCGI...
  taskkill /F /IM php-cgi.exe > nul
  exit

 

最新文章

  1. 每天一个 Linux 命令(22):find 命令的参数详解
  2. Foundation框架—— 数组 (NSArray NSMutableArray )
  3. map的使用
  4. DrawIndexedPrimitive参数详解
  5. javascript面向对象和原型
  6. SQL SERVER ->> Wait Stats
  7. 你所不知道的Html5那些事(一)
  8. Codeforces 715A & 716C Plus and Square Root【数学规律】 (Codeforces Round #372 (Div. 2))
  9. 最流行的android组件大全
  10. mongodb----pymongo的用法
  11. XJOI1564最小距离问题
  12. JDK8-废弃永久代(PermGen)迎来元空间(Metaspace)
  13. NodeJS多进程
  14. 使用react-navigation提示undefind is not a function
  15. FT_ND_API.dll
  16. java redis client jedis 测试及常用命令
  17. rbac之 权限粒度控制到按钮级别
  18. VBA 代码
  19. in 型子查询引出的陷阱
  20. javascript 正则表达式校验方式写法

热门文章

  1. vue实例相关
  2. josn的格式化
  3. git指令详解总结
  4. 了解AutoCAD对象层次结构 —— 3 ——数据库
  5. Python中xlutils解析
  6. POJ 3481 Double Queue
  7. python查找读写文件
  8. Quartus prime16.0 与modelsim ae 联调
  9. HDOJ5551 Huatuo's Medicine
  10. [luogu1452]Beauty Contest【凸包+旋转卡壳】